说明
Scheduler(继承于Ref; cocos/base模块下)
调度器的相关操作在Node中也有定义,常用的几个操作如下:
schedule
/*自定义定时器*///调用成员函数void schedule(SEL_SCHEDULE selector); , float interval);unsigned int repeat delay);//调用lambda函数的定时器多一个string& key 参数
scheduleOnce(一次性定时器)
//调用lambda函数,最后一个参数为key,可以根据该key,停止调用该函数scheduleOnce([](float dt){ CCLOG("hi" },1 "aa"//调用类的成员函数schedule_selector(Test2::callback),76)"> );
scheduleUpdate
* Unschedules the "update" method. * @see scheduleUpdate(); */ unscheduleUpdate /** * Unschedules a custom selector. * @see `schedule(SEL_SCHEDULE,float,unsigned int,float)` * * @param selector A function wrapped as a selector * @lua NA unschedule * Unschedules a lambda function * @param key The key of the lambda function to be unscheduledconst stdstring &key * Unschedule all scheduled selectors and lambda functions: custom selectors,and the 'update' selector and lambda functions * Actions are not affected by this method. unscheduleAllCallbacks();