axmol/template/CCXAppWiz.vs/CCXAppWiz/Templates/1033/Classes/AppDelegate.cpp

67 lines
1.5 KiB
C++
Raw Normal View History

#include "AppDelegate.h"
#include "cocos2d.h"
[! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE]
#include "SimpleAudioEngine.h"
using namespace CocosDenshion;
[! endif]
#include "HelloWorldScene.h"
using namespace cocos2d;
AppDelegate::AppDelegate()
:m_pMainWnd(NULL)
{
}
AppDelegate::~AppDelegate()
{
[! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE]
SimpleAudioEngine::release();
[! endif]
}
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()
{
CCDirector::sharedDirector()->pause();
[! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE]
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
[! endif]
}
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->resume();
[! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE]
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
[! endif]
}