//呼吸脚本

cc.Class({
    extends: cc.Component,

    properties: {
        
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {
    // },
    
    onEnable(){
        this.startScale = 0;
        this.endScale = 0;

        this.startScale = this.node.scale;
        this.endScale = this.startScale * 1.1;
    },
    
    start () {
        //呼吸效果
        // this.node.runAction(cc.repeatForever(cc.sequence(cc.scaleTo(1, 1.1), cc.scaleTo(1,1)) ));
        if(this.startScale == 0)return;
        if(this.endScale == 0)return;
        
        if(this.node){
            this.node.runAction(
                cc.repeatForever(
                    cc.sequence(
                        cc.scaleTo(0.2, this.endScale),
                        cc.scaleTo(0.2, this.startScale),
                        cc.delayTime(0.5)
                    )
                )
            );
        }
    },

    // update (dt) {},
});
