代码改变世界

cocos2d-x JS 利用重复动作实现动画播放(实现倒计时)

2017-05-08 14:35  罗任德  阅读(1815)  评论(0编辑  收藏  举报

cocos2d-js: cc.delayTime() and cc.repeatForever() don't work together in cc.sequence()  

 

 

 1          this.numm = 100; //设置倒计时总数为100    
 2         
 3       var act = cc.sequence(cc.callFunc(function() {
 4 
 5                 //在这里面可自定义事件(在此我以倒计时为例)
 6 
 7                 this.numm --;
 8                 this.table_time.setString(this.numm);//赋值到标签对象
 9                 if(this.numm <= -1){//加个判断避免出错
10                    
11                       this.table_time.setString("0");
12            
13                 }
14             }, this), cc.delayTime(1));  //延时一秒  
15             this.runAction(cc.repeat(act, 100));  //重复动作,这里100为执行100次