/*
 * LogoAnimated
 *
 * animated logo for menu
 * 
 * 
 */


export default class LogoAnimated extends Phaser.Sprite {

    constructor(game, x, y) {

        super(game, x, y, 'sts-logo');

        this.game = game;

        this.anchor.set(0.5);

    }

    tween_rotate(duration = 1500, delay = 1500) {
        this.tween = this.game.add.tween(this).to({
            angle: +90
        }, delay, Phaser.Easing.Bounce.Out, true, duration);

        this.tween.onStart.add(this.tween_onStart, this);

        this.tween.onLoop.add(this.tween_onLoop, this);

        this.tween.onComplete.add(this.tween_onComplete, this);
    }

    tween_onStart() {

        //	Turn off the delay, so it loops seamlessly from here on
        // this.menu_logo_tween.delay(0);

        console.log('onStart');

    }

    tween_onLoop() {

        // NOT WORKING IN 2.4.6!!!

        // this.bounces--;
        //
        // if (this.menu_logo.frame === 5)
        // {
        //     this.menu_logo.frame = 0;
        // }
        // else
        // {
        //     this.menu_logo.frame++;
        // }
        //
        // console.log('onLoop', this.bounces);

    }


    tween_onComplete() {

        // this.tween = this.game.add.tween(this).to({
        //     x: 800 - this.width
        // }, 2000, Phaser.Easing.Exponential.Out, true);
        //
        // console.log('onComplete');

    }


}
