I want to Pause a CCNode for a while and after that resume it again. when I use below code separately they work but when I want to resume this CCNode for a specific time when a button clicked it dose't work and occur an Assertion failed(that is: pElement->paused == bPaused ).
我想暂停一个CCNode一段时间,然后再恢复它。当我单独使用下面的代码时,它们可以工作,但是当我想在单击按钮时恢复这个CCNode的特定时间时,它不会工作,并发生断言失败(即:pElement->pause == bpause)。
//for pausing
this->pauseSchedulerAndActions();
//for resuming
this->resumeSchedulerAndActions();
I use below codes:
我用下面的代码:
#define TIME_FOR_RESUME 5.0f
//function that called when my button click
void myClass::myFunc(CCObject * pSender)
{
this->pauseSchedulerAndActions();
this->scheduleOnce(schedule_selector(myClass::myResumeFunction), TIME_FOR_RESUME);
}
void myClass::myResumeFunction(float dt)
{
this->resumeSchedulerAndActions();
}
1 个解决方案
#1
1
you can use this for pausing
你可以用这个暂停
this->unscheduleAllSelectors();
and this for resume
这对于恢复
this->scheduleUpdate();
#1
1
you can use this for pausing
你可以用这个暂停
this->unscheduleAllSelectors();
and this for resume
这对于恢复
this->scheduleUpdate();