2019独角兽企业重金招聘Python工程师标准>>>
用update来实现定时
//长按处理update: function (delta) {cc.log("update + "+delta);this.totalTime+=delta;if(this.totalTime>=TOUCH_LONG_TIMER_INVOKE){this.stopTimer();this.invokeTouchLong();}},stopTimer: function () {this.unscheduleUpdate ();this.totalTime=0;},startTimer: function () {this.isTouchLong=false;this.scheduleUpdate ();},invokeTouchLong: function () {cc.log("长按")this.isTouchLong=true;},ctor: function (id) {this._super();btn.addTouchEventListener (function (a1,type) {if(type ==0){//按下self.startTimer ();}if(type==1){ /移动move=true; self.stopTimer ();}if(type==2){ // 结束self.stopTimer ();if(!move && ! self.isTouchLong){cc.log("click ");}move=false;}})