1.帧循环定时器
scheduleUpdate();//帧循环定时器 每帧都会被调用,用于对实时性要求比较高的,例如碰撞检测
void update(float dt) // 调用方法
unscheduleUpdate() //关闭定时器
2.一次性定时器
scheduleOnce( schedule_selector(回调函数) , dt )
3.自定义定时器
void Node::schedule(SEL_SCHEDULE selector)
{
this->schedule(selector, 0.0f, CC_REPEAT_FOREVER, 0.0f);
}
void Node::schedule(SEL_SCHEDULE selector, float interval)
{
this->schedule(selector, interval, CC_REPEAT_FOREVER, 0.0f);
}
void Node::schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay)
{
CCASSERT( selector, "Argument must be non-nil");
CCASSERT( interval >=0, "Argument must be positive");
_scheduler->schedule(selector, this, interval , repeat, delay, !_running);
}
全部调用第三个函数
void Node::schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay)
参数 1 回调函数
2 调用时间间隔
3.重复次数
4.延时时间