import Phaser from 'phaser'
import CinematicScreen from '../cinematic-screen'

export default class Intro3 extends CinematicScreen {
    constructor(game, parent, name) {
        super(game, parent, name);

        this.create();
    }

    create() {
        this.bg = game.add.sprite(480, 320, 'intro_3_bg');
        this.nina = game.add.sprite(495, 325, 'intro_3_nina');

        this.bg.anchor.setTo(0.5);
        this.nina.anchor.setTo(0.5);
        this.bg.scale.setTo(1.05);

        this.add(this.bg);
        this.add(this.nina);
    }

    appearAnimation() {
        this.game.add.tween(this.nina).to({ x: "-55" }, 1200, Phaser.Easing.Sinusoidal.Out, true).onComplete.add(() => {
            this.game.time.events.add(100, () => {
                this.nina.scale.setTo(-1, 1);
                this.nina.x -= 10;
                this.game.time.events.add(200, () => {
                    this.game.add.tween(this.nina).to({ y: "-5" }, 250, Phaser.Easing.Quadratic.InOut, true, 0, 2, true);
                    this.game.add.tween(this.nina).to({ x: "+105" }, 1750, Phaser.Easing.Sinusoidal.Out, true);
                }, this);
            }, this)

        }, this);

        this.game.add.tween(this.nina).to({ y: "-5" }, 250, Phaser.Easing.Quadratic.InOut, true, 0, 1, true);
        this.game.add.tween(this.bg).to({ x: "-1" }, 400, Phaser.Easing.Quadratic.InOut, true, 0, 2, true);
    }
}
