class SceneError extends Phaser.Scene {

    constructor ()
    {
        super({ key: 'SceneError', active: true });
    }

    create (data)
    {
        this.parent = data.scene;
        this.x = data.x;
        this.y = data.y;
        this.vDelta = data.vDelta;

        this.strip = this.add.image(640, 360 + this.vDelta, 'msgstrip');

        this.txtX = 600;
        this.txtY = 345;
        this.Txt = this.add.text(this.txtX, this.txtY + this.vDelta, 668);
        this.Txt.setScale(2.0);

        this.scene.sleep();
    }

    onOrientationChange (offs)
    {
        this.vDelta = offs;
        
        this.strip.setPosition(640, 360 + this.vDelta);
        this.Txt.setPosition(this.Txt.x, this.txtY + this.vDelta);
    }        

    setMessage (message)
    {
        this.tweens.killTweensOf(this.Txt);
        this.Txt.setAlpha(1.0);

        this.Txt.setText(message);

        this.Txt.x = (1280 - this.Txt.width * 2) / 2;

        this.scene.wake();
        this.scene.bringToTop();
    }

    setBlinkingMessage (message)
    {
        this.Txt.setText(message);
        this.Txt.setAlpha(1.0);

        this.Txt.x = (1280 - this.Txt.width * 2) / 2;

        this.tweens.add({

            targets: this.Txt,
            ease: 'Linear',
            duration: 1000,
            alpha: 0,
            yoyo: true,
            repeat: -1,
        });

        this.scene.wake();
        this.scene.bringToTop();
    }

    clearMessage ()
    {
        this.tweens.killTweensOf(this.Txt);
        this.Txt.setAlpha(1.0);

        this.scene.sleep();
    }
}
