2013-06-28 11:46:39 +08:00
|
|
|
#include "AppDelegate.h"
|
|
|
|
#include "HelloWorldScene.h"
|
|
|
|
|
|
|
|
USING_NS_CC;
|
|
|
|
|
|
|
|
AppDelegate::AppDelegate() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
AppDelegate::~AppDelegate()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AppDelegate::applicationDidFinishLaunching() {
|
|
|
|
// initialize director
|
2013-07-12 11:50:36 +08:00
|
|
|
Director* pDirector = Director::getInstance();
|
2013-07-12 13:11:21 +08:00
|
|
|
EGLView* pEGLView = EGLView::getInstance();
|
2013-06-28 11:46:39 +08:00
|
|
|
|
|
|
|
pDirector->setOpenGLView(pEGLView);
|
|
|
|
|
2013-07-26 18:18:58 +08:00
|
|
|
pEGLView->setDesignResolutionSize(960.0f, 640.0f, ResolutionPolicy::NO_BORDER);
|
2013-06-28 11:46:39 +08:00
|
|
|
|
|
|
|
// turn on display FPS
|
|
|
|
pDirector->setDisplayStats(true);
|
|
|
|
|
|
|
|
// set FPS. the default value is 1.0/60 if you don't call this
|
|
|
|
pDirector->setAnimationInterval(1.0 / 60);
|
|
|
|
|
|
|
|
// create a scene. it's an autorelease object
|
|
|
|
Scene *pScene = HelloWorld::scene();
|
|
|
|
|
|
|
|
// run
|
|
|
|
pDirector->runWithScene(pScene);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
|
|
|
|
void AppDelegate::applicationDidEnterBackground() {
|
2013-07-12 11:50:36 +08:00
|
|
|
Director::getInstance()->stopAnimation();
|
2013-06-28 11:46:39 +08:00
|
|
|
|
|
|
|
// if you use SimpleAudioEngine, it must be pause
|
2013-07-29 15:17:54 +08:00
|
|
|
// SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
|
2013-06-28 11:46:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// this function will be called when the app is active again
|
|
|
|
void AppDelegate::applicationWillEnterForeground() {
|
2013-07-12 11:50:36 +08:00
|
|
|
Director::getInstance()->startAnimation();
|
2013-06-28 11:46:39 +08:00
|
|
|
|
|
|
|
// if you use SimpleAudioEngine, it must resume here
|
2013-07-29 15:17:54 +08:00
|
|
|
// SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
|
2013-06-28 11:46:39 +08:00
|
|
|
}
|