Cocos2dx-js全局定时器写法

            this._onlineScheduleHandle = this.updateOnlineTime.bind(this);
            cc.director.getScheduler().unschedule(this._onlineScheduleHandle, this);
            cc.director.getScheduler().schedule(this._onlineScheduleHandle, this, 1.1,cc.REPEAT_FOREVER, 0, false, "keyCountDownTime");


Cocos2d-js中,回调函数一定要先保存起来,例如            this._onlineScheduleHandle = this.updateOnlineTime.bind(this);

其次   cc.director.getScheduler().schedule(this._onlineScheduleHandle, this, 1.1,cc.REPEAT_FOREVER, 0, false, "keyCountDownTime");这个参数一定要写全,否则出问题。

你可能感兴趣的:(Cocos2d-JS)