2010-11-18 10:39:59 +08:00
|
|
|
#include "AppDelegate.h"
|
|
|
|
|
2010-11-18 17:47:28 +08:00
|
|
|
[! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE]
|
|
|
|
#include "SimpleAudioEngine.h"
|
|
|
|
|
|
|
|
[! endif]
|
2010-11-18 10:39:59 +08:00
|
|
|
#include "HelloWorldScene.h"
|
2010-11-18 17:47:28 +08:00
|
|
|
[! if CCX_USE_UI_RESOURCE]
|
|
|
|
|
2010-11-18 10:39:59 +08:00
|
|
|
#include "Resource.h"
|
2010-11-18 17:47:28 +08:00
|
|
|
[! endif]
|
2010-11-18 10:39:59 +08:00
|
|
|
|
|
|
|
using namespace cocos2d;
|
|
|
|
|
|
|
|
AppDelegate::AppDelegate()
|
|
|
|
:m_pMainWnd(NULL)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
AppDelegate::~AppDelegate()
|
|
|
|
{
|
2010-11-26 15:36:44 +08:00
|
|
|
[! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE]
|
|
|
|
SimpleAudioEngine::release();
|
|
|
|
[! endif]
|
2010-11-18 10:39:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AppDelegate::applicationDidFinishLaunching()
|
|
|
|
{
|
2010-11-19 14:43:13 +08:00
|
|
|
// init the window
|
|
|
|
if (!(m_pMainWnd = new CCXEGLView(this)) ||
|
|
|
|
! m_pMainWnd->Create(&TRectangle(0,0,GetScreenWidth(),GetScreenHeight())))
|
|
|
|
{
|
2010-11-18 10:39:59 +08:00
|
|
|
CCX_SAFE_DELETE(m_pMainWnd);
|
2010-11-19 14:43:13 +08:00
|
|
|
return false;
|
|
|
|
}
|
2010-11-18 10:39:59 +08:00
|
|
|
|
|
|
|
// init director
|
|
|
|
CCDirector * pDirector = CCDirector::sharedDirector();
|
|
|
|
pDirector->setOpenGLView(m_pMainWnd);
|
|
|
|
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
2010-11-19 14:43:13 +08:00
|
|
|
// pDirector->setDeviceOrientation(kCCDeviceOrientationPortrait);
|
2010-11-18 10:39:59 +08:00
|
|
|
pDirector->setDisplayFPS(true);
|
|
|
|
|
|
|
|
// set the resource path
|
2010-11-18 17:47:28 +08:00
|
|
|
CCFileUtils::setResourcePath("/NEWPLUS/TDA_DATA/Data/[!output PROJECT_NAME]/");
|
|
|
|
[! if CCX_USE_UI_RESOURCE]
|
2010-11-18 10:39:59 +08:00
|
|
|
|
2010-11-19 14:43:13 +08:00
|
|
|
// cocos2d find image in ResourceEntry first, in ResourcePath second.
|
|
|
|
// set the ResourceEntry,
|
|
|
|
CCFileUtils::setResourceEntry(&[!output PROJECT_NAME]ResourceEntry);
|
|
|
|
|
2010-11-18 10:39:59 +08:00
|
|
|
// set the Images ResInfo (name and ResID)
|
2010-11-18 17:47:28 +08:00
|
|
|
CCFileUtils::setResourceInfo(ResInfo, sizeof(ResInfo) / sizeof(T_ResourceInfo));
|
|
|
|
[! endif]
|
2010-11-18 10:39:59 +08:00
|
|
|
|
|
|
|
CCScene * pScene = HelloWorld::scene();
|
|
|
|
|
2010-11-19 14:43:13 +08:00
|
|
|
pDirector->runWithScene(pScene);
|
2010-11-18 10:39:59 +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()
|
|
|
|
{
|
2010-12-03 15:27:55 +08:00
|
|
|
CCDirector::sharedDirector()->pause();
|
2010-11-18 17:47:28 +08:00
|
|
|
[! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE]
|
2010-11-19 14:43:13 +08:00
|
|
|
|
|
|
|
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
|
2010-11-18 17:47:28 +08:00
|
|
|
[! endif]
|
2010-11-18 10:39:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// this function will be called when the app is active again
|
|
|
|
void AppDelegate::applicationWillEnterForeground()
|
|
|
|
{
|
2010-12-03 15:27:55 +08:00
|
|
|
CCDirector::sharedDirector()->resume();
|
2010-11-18 17:47:28 +08:00
|
|
|
[! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE]
|
2010-11-19 14:43:13 +08:00
|
|
|
|
|
|
|
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
|
2010-11-18 17:47:28 +08:00
|
|
|
[! endif]
|
2010-11-18 10:39:59 +08:00
|
|
|
}
|