2013-02-19 15:38:30 +08:00
|
|
|
#include "AppDelegate.h"
|
|
|
|
#include "HelloWorldScene.h"
|
|
|
|
|
|
|
|
USING_NS_CC;
|
|
|
|
|
|
|
|
AppDelegate::AppDelegate() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
AppDelegate::~AppDelegate()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AppDelegate::applicationDidFinishLaunching() {
|
|
|
|
// initialize director
|
2013-09-19 07:50:26 +08:00
|
|
|
auto director = Director::getInstance();
|
2014-01-31 13:17:55 +08:00
|
|
|
auto glview = director->getOpenGLView();
|
|
|
|
if(!glview) {
|
|
|
|
glview = GLView::create("My Game");
|
|
|
|
director->setOpenGLView(glview);
|
|
|
|
}
|
2013-02-19 15:38:30 +08:00
|
|
|
|
|
|
|
// turn on display FPS
|
2013-07-28 00:16:16 +08:00
|
|
|
director->setDisplayStats(true);
|
2013-02-19 15:38:30 +08:00
|
|
|
|
|
|
|
// set FPS. the default value is 1.0/60 if you don't call this
|
2013-07-28 00:16:16 +08:00
|
|
|
director->setAnimationInterval(1.0 / 60);
|
2013-02-19 15:38:30 +08:00
|
|
|
|
|
|
|
// create a scene. it's an autorelease object
|
2013-09-19 07:50:26 +08:00
|
|
|
auto scene = HelloWorld::createScene();
|
2013-02-19 15:38:30 +08:00
|
|
|
|
|
|
|
// run
|
2013-07-28 00:16:16 +08:00
|
|
|
director->runWithScene(scene);
|
2013-02-19 15:38:30 +08:00
|
|
|
|
|
|
|
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-02-19 15:38:30 +08:00
|
|
|
|
|
|
|
// if you use SimpleAudioEngine, it must be pause
|
2014-04-22 13:20:07 +08:00
|
|
|
// SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
|
2013-02-19 15:38:30 +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-02-19 15:38:30 +08:00
|
|
|
|
|
|
|
// if you use SimpleAudioEngine, it must resume here
|
2014-04-22 13:20:07 +08:00
|
|
|
// SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
|
2013-02-19 15:38:30 +08:00
|
|
|
}
|