add ccdirector::pause for helloworld

This commit is contained in:
Walzer 2010-10-29 06:48:00 +00:00
parent c774653018
commit d2d9375376
3 changed files with 24 additions and 5 deletions

View File

@ -92,6 +92,18 @@ Boolean HelloWorldAppDelegate::EventHandler(EventType* pEvent)
return (bHandled) ? TRUE : CCXApplication::EventHandler(pEvent);
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void HelloWorldAppDelegate::applicationDidEnterBackground()
{
CCDirector::getSharedDirector()->stopAnimation();
}
// this function will be called when the app is active again
void HelloWorldAppDelegate::applicationWillEnterForeground()
{
CCDirector::getSharedDirector()->startAnimation();
}
// application main entry
Int32 TG3AppMain(const TUChar * pAppID, UInt32 nCmd, void * pCmdParam)
{

View File

@ -16,6 +16,8 @@ public:
virtual bool initCocos2d();
virtual Boolean EventHandler(EventType * pEvent);
virtual void applicationDidEnterBackground();
virtual void applicationWillEnterForeground();
protected:
TRectangle m_rcWnd;

View File

@ -89,14 +89,19 @@ Boolean AppDelegate::EventHandler(EventType* pEvent)
return (bHandled) ? TRUE : CCXApplication::EventHandler(pEvent);
}
// This function be called when the app unactived,(if coming a call,it's be called too)
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
CCDirector::getSharedDirector()->stopAnimation();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::getSharedEngine()->pauseBackgroundMusic();
}
// This function be called when the app actived again
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::getSharedDirector()->startAnimation();
// SimpleAudioEngine::getSharedEngine()->resumeBackgroundMusic();
}