2012-04-19 14:35:52 +08:00
|
|
|
#include "AppDelegate.h"
|
|
|
|
|
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "tests/controller.h"
|
|
|
|
#include "SimpleAudioEngine.h"
|
|
|
|
|
|
|
|
USING_NS_CC;
|
|
|
|
using namespace CocosDenshion;
|
|
|
|
|
|
|
|
AppDelegate::AppDelegate()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
AppDelegate::~AppDelegate()
|
|
|
|
{
|
|
|
|
// SimpleAudioEngine::end();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AppDelegate::applicationDidFinishLaunching()
|
|
|
|
{
|
|
|
|
// initialize director
|
|
|
|
CCDirector *pDirector = CCDirector::sharedDirector();
|
|
|
|
pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());
|
|
|
|
|
|
|
|
// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
|
2012-06-08 17:34:15 +08:00
|
|
|
pDirector->enableRetinaDisplay(true);
|
2012-04-19 14:35:52 +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);
|
|
|
|
|
|
|
|
CCScene * pScene = CCScene::node();
|
|
|
|
CCLayer * pLayer = new TestController();
|
|
|
|
pLayer->autorelease();
|
|
|
|
|
|
|
|
pScene->addChild(pLayer);
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
CCDirector::sharedDirector()->pause();
|
|
|
|
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
|
|
|
|
SimpleAudioEngine::sharedEngine()->pauseAllEffects();
|
|
|
|
}
|
|
|
|
|
|
|
|
// this function will be called when the app is active again
|
|
|
|
void AppDelegate::applicationWillEnterForeground()
|
|
|
|
{
|
|
|
|
CCDirector::sharedDirector()->resume();
|
|
|
|
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
|
|
|
|
SimpleAudioEngine::sharedEngine()->resumeAllEffects();
|
|
|
|
}
|