// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Label)
    label: cc.Label = null;

    @property
    text: string = 'hello';

    // LIFE-CYCLE CALLBACKS:

    private aning;
    onLoad() {
        this.aning = false;
        this.showAni();
    }
    protected onDestroy(): void {
        cc.Tween.stopAll();
        this.unscheduleAllCallbacks();
    }
    showAni() {
        if (this.aning) return;
        if (this.node && this.node.active) {
            // this.node.y -= 200;
            // this.aning = true;
            cc.tween(this.node).repeatForever(
                cc.tween()
                    .by(.5, { y: -50 })
                    .by(.5, { y: 50 }).start()
            ).start();
            //     this.aning = false;
            //     this.showAni();
            // }).start();
        }
    }
    update(dt) {
        // this.showAni();
    }
}
