Actually I want to resume a game after 5 sec of pause game status?? I did this, but it’s not working…
void HelloWorld::pauseGame()
{
CCLog(“Inside pauseGame”);
this~~>unscheduleAllSelectors;
CCDirector::sharedDirector~~>pause;
this~~>resumeGame; // This line working. It’s call resume function
this~~>schedule( schedule_selector(HelloWorld::resumeGame), 5.0f); //This line Not working. It’s not call resume function
}
After you invoke “CCDirector::sharedDirector()>pause", all schedule will be paused, so this>schedule() will not take effect.
Look at here
<pre>
void CCDirector::drawScene(void)
{
// calculate”global" dt
calculateDeltaTime();
//tick before glClear: issue #533
if (! m_bPaused)
{
CCScheduler::sharedScheduler()->tick(m_fDeltaTime);
}
…
}
In my opinion, you should use system timer to compute time after invoking “CCDirector::sharedDirector()->pause()”. But don’t use this method in the other logic of your game.
Does anybody have a better method?
The main loop of engine is CCDisplayLinkDirector::mainLoop().
Different platforms invoke this method to draw frames.
May be you can stop invoke this method to achieve your requirement.
Hi, John Smith
>
After you invoke “CCDirector::sharedDirector()>pause", all schedule will be paused, so this>schedule() will not take effect.
Look at here
[…]
how about provide a function pointer to CCDirector, which will be called in each frame even if the CCDirector been paused?
<pre>
void CCDirector::drawScene(void)
{
// calculate”global" dt
calculateDeltaTime();
// here
*(this->ticker)(fDeltaTime);
//tick before glClear: issue #533
if (! m_bPaused)
{
CCScheduler::sharedScheduler()->tick(m_fDeltaTime);
}
…
}
how about provide a function pointer to CCDirector, which will be called in each frame even if the CCDirector been paused?
[…]
It’s a way to achieve that, but you should calculate the delta time to total time, because you can not use the schedule after game is paused.
Just have a try.
Timothy Zhang wrote:
> how about provide a function pointer to CCDirector, which will be called in each frame even if the CCDirector been paused?
> […]
>
It’s a way to achieve that, but you should calculate the delta time to total time, because you can not use the schedule after game is paused.
Just have a try.
In fact we are just doing like that in our games. delta time is a bit meaningless here.
It would be very nice if it would be added to next release.