#include "AppDelegate.h" [! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] #include "SimpleAudioEngine.h" using namespace CocosDenshion; [! endif] #include "HelloWorldScene.h" using namespace cocos2d; [! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] using namespace CocosDenshion; [! endif] AppDelegate::AppDelegate() :m_pMainWnd(NULL) { } AppDelegate::~AppDelegate() { [! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] SimpleAudioEngine::end(); [! endif] } bool AppDelegate::applicationDidFinishLaunching() { // init the window if (!(m_pMainWnd = new CCXEGLView(this)) || ! m_pMainWnd->Create(&TRectangle(0,0,GetScreenWidth(),GetScreenHeight()))) { CCX_SAFE_DELETE(m_pMainWnd); return false; } // init director CCDirector * pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(m_pMainWnd); pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); // pDirector->setDeviceOrientation(kCCDeviceOrientationPortrait); pDirector->setDisplayFPS(true); // set the resource path CCFileUtils::setResourcePath("/NEWPLUS/TDA_DATA/Data/[!output PROJECT_NAME]/"); CCScene * pScene = HelloWorld::scene(); 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(); [! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); [! endif] } // this function will be called when the app is active again void AppDelegate::applicationWillEnterForeground() { CCDirector::sharedDirector()->resume(); [! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); [! endif] }