mirror of https://github.com/axmolengine/axmol.git
add ccdirector::pause for helloworld
This commit is contained in:
parent
c774653018
commit
d2d9375376
|
@ -49,7 +49,7 @@ bool HelloWorldAppDelegate::initCocos2d()
|
|||
CCDirector::getSharedDirector()->setOpenGLView(m_pMainWnd);
|
||||
// set to landscape mode
|
||||
CCDirector::getSharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
||||
|
||||
|
||||
// load background image texture and get window size
|
||||
CCTexture2D * pTexture = CCTextureCache::sharedTextureCache()->addImage(IMG_PATH);
|
||||
CGSize size = CCDirector::getSharedDirector()->getWinSize();
|
||||
|
@ -57,8 +57,8 @@ bool HelloWorldAppDelegate::initCocos2d()
|
|||
// create sprite instance
|
||||
CCSprite * pSprite = CCSprite::spriteWithTexture(pTexture);
|
||||
pSprite->setPosition(CGPoint(size.width / 2, size.height / 2));
|
||||
|
||||
// create layer instance
|
||||
|
||||
// create layer instance
|
||||
CCLayer * pLayer = MyLayer::node();
|
||||
pLayer->addChild(pSprite);
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -16,6 +16,8 @@ public:
|
|||
|
||||
virtual bool initCocos2d();
|
||||
virtual Boolean EventHandler(EventType * pEvent);
|
||||
virtual void applicationDidEnterBackground();
|
||||
virtual void applicationWillEnterForeground();
|
||||
|
||||
protected:
|
||||
TRectangle m_rcWnd;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue