1.取消一个定时器 所有的定时器都用下面的额这个方法取消 C++ //void unschedule(SEL_SCHEDULE selector); unschedule(schedule_selector(HelloWorld::callFunc)); 1 2 //void unschedule(SEL_SCHEDULE selector); unschedule(schedule_selector(HelloWorld::callFunc)); 或者取消当前node的全部定时器 C++ void unscheduleAllSelectors(void); 1 voidunscheduleAllSelectors(void); 2.创建一个定时器 添加一个定时器,时间间隔为游戏帧间隔 This method will be called every frame. C++ schedule(schedule_selector(HelloWorld::callFunc)); void HelloWorld::callFunc( float fDelay ) { CCLog("callFunc %f",fDelay); } 1 2 3 4 5 6 schedule(schedule_selector(HelloWorld::callFunc)); voidHelloWorld::callFunc(float fDelay) { CCLog("callFunc %f",fDelay); } 创建一个自定义时间间隔的定时器,时间间隔不能小于帧间隔 C++ schedule(schedule_selector(HelloWorld::callFunc),1.5f); void HelloWorld::callFunc( float fDelay ) { CCLog("callFunc %f",fDelay); } 1 2 3 4 5 6 schedule(schedule_selector(HelloWorld::callFunc),1.5f); voidHelloWorld::callFunc(float fDelay) { CCLog("callFunc %f",fDelay); } 先1.0秒之后执行一次,再每1.5秒执行一次共5次(注:如果最后一个参数为0的话会1.5秒执行6次) C++ schedule(schedule_selector(HelloWorld::callFunc),1.5,5,1.0); void HelloWorld::callFunc( float fDelay ) { CCLog("callFunc %f",fDelay); } 1 2 3 4 5 6 schedule(schedule_selector(HelloWorld::callFunc),1.5,5,1.0); voidHelloWorld::callFunc(float fDelay) { CCLog("callFunc %f",fDelay); }