// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.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

cc.Class({
    extends: cc.Component,

    properties: {
        // foo: {
        //     // ATTRIBUTES:
        //     default: null,        // The default value will be used only when the component attaching
        //                           // to a node for the first time
        //     type: cc.SpriteFrame, // optional, default is typeof default
        //     serializable: true,   // optional, default is true
        // },
        // bar: {
        //     get () {
        //         return this._bar;
        //     },
        //     set (value) {
        //         this._bar = value;
        //     }
        // },
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},
    playTween: null,
    start () {

    },

    play() {
        if(this.playTween) {
            this.playTween.stop();
            this.node.scale = 1;
        }
        this.playTween = cc.tween(this.node)
            .by(0.5, { scale: 0.1 })
            .by(0.5, { scale: -0.1 })
            .union()
            .repeatForever()
            .start()
    },

    stop() {
        if(this.playTween) {
            this.playTween.stop();
            this.node.scale = 1;
            this.playTween = null;
        }
    }
    // update (dt) {},
});
