GameCorder.net

このエントリーをはてなブックマークに追加

About schedule in Cocos2dx

When wanto to do something every seconds for example.
We can do to use schedule in cocos2dx.

In this example do something every seconds.


// 1.schedule
schedule(schedule_selector(TouchNumberScene::countTime), 1);

// 2.function take place in every seconds in TouchNumberScene class
// Arg time is always 1 which is defined schedule_selector
void TouchNumberScene::countTime(float time){
    // write things in every seconds
}
		

In the last see schedule in Node class


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);
}

This is available in cocos2dx 3.15.1