class SpriteEx extends Phaser.GameObjects.Sprite
{
    constructor (scene, reel, x, y, key, animtype) //0 - symbols, 1 - scatter/star symbols
    {
        super(scene, x, y, key);
        
        this.scene.add.existing(this);
        this.reel = reel;
        this.animtype = animtype;

        this.isPlaying = false;
    }
    
    playAnimation ()
    {
        if(this.anims.currentAnim != null)
        {
            this.play(this.anims.currentAnim.key, false);
        }

        this.scale(400, 1);

        this.isPlaying = true;
    }

    stopAnimation ()
    {
        this.scene.tweens.killTweensOf(this);

        this.stop();

        if (this.anims.currentAnim != null)
        {
            this.play(this.anims.currentAnim.key, false, 0);
            this.anims.stop();
        }
        
        this.setScale(1.0);
        
        this.isPlaying = false;
    }

    destroyAnimation ()
    {
        this.stopAnimation();

        if (this.anims.currentAnim != null)
        {
            let key = this.anims.currentAnim.key;
            this.anims.animationManager.remove(key);

            this.anims.currentAnim = null;
        }
    }

    setTextureKey (key, animtype)
    {
        this.setTexture(key);

        this.setScale(1.0);

        this.animtype = animtype;
    }

    getTextureKey ()
    {
        return this.texture.key;
    }
    
    scale (duration, repeat)
    {
        this.scene.tweens.add({
            targets: this,
            ease: 'Linear',
            duration: duration,
            scale: 1.2,
            repeat: repeat,
            yoyo: true,
            callbackScope: this,
            onComplete: function ()
            {
                this.setScale(1.0);
            },
        });
    }

    preUpdate (time, delta)
    {
       super.preUpdate(time, delta);
    }
}