2010-11-16 11:25:33 +08:00
|
|
|
#include "AppDelegate.h"
|
|
|
|
#include "cocos2d.h"
|
2010-12-03 15:27:55 +08:00
|
|
|
[! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE]
|
|
|
|
#include "SimpleAudioEngine.h"
|
2010-12-25 15:44:26 +08:00
|
|
|
using namespace CocosDenshion;
|
2010-11-16 11:25:33 +08:00
|
|
|
|
2010-12-03 15:27:55 +08:00
|
|
|
[! endif]
|
2010-11-16 11:25:33 +08:00
|
|
|
#include "HelloWorldScene.h"
|
|
|
|
|
|
|
|
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-16 11:25:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AppDelegate::applicationDidFinishLaunching()
|
|
|
|
{
|
|
|
|
// init the window
|
|
|
|
if (!(m_pMainWnd = new CCXEGLView()) ||
|
|
|
|
! m_pMainWnd->Create(L"cocos2d-win32", 320, 480) )
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
CCScene * pScene = HelloWorld::scene();
|
|
|
|
|
|
|
|
pDirector->runWithScene(pScene);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppDelegate::applicationDidEnterBackground()
|
|
|
|
{
|
2010-12-03 15:27:55 +08:00
|
|
|
CCDirector::sharedDirector()->pause();
|
|
|
|
[! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE]
|
|
|
|
|
|
|
|
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
|
|
|
|
[! endif]
|
2010-11-16 11:25:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AppDelegate::applicationWillEnterForeground()
|
|
|
|
{
|
2010-12-03 15:27:55 +08:00
|
|
|
CCDirector::sharedDirector()->resume();
|
|
|
|
[! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE]
|
|
|
|
|
|
|
|
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
|
|
|
|
[! endif]
|
2010-11-16 11:25:33 +08:00
|
|
|
}
|