mirror of https://github.com/axmolengine/axmol.git
76 lines
1.9 KiB
C++
76 lines
1.9 KiB
C++
// Application application cpp file.
|
|
|
|
// Original file name: cocosTemplateApp.cpp
|
|
// Generated by TOPS Builder:Project wizard,Date:2010-09-27
|
|
|
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "AppDelegate.h"
|
|
#include "HelloWorldScene.h"
|
|
#include "Resource.h"
|
|
|
|
using namespace cocos2d;
|
|
|
|
extern const AppResourceEntry cocosTemplateResourceEntry;
|
|
|
|
bool AppDelegate::applicationDidFinishLaunching()
|
|
{
|
|
// init the window
|
|
if (!(m_pMainWnd = new CCXEGLView(this)) ||
|
|
! m_pMainWnd->Create(&TRectangle(0,0,GetScreenWidth(),GetScreenHeight())))
|
|
{
|
|
delete m_pMainWnd;
|
|
return false;
|
|
}
|
|
|
|
// init director
|
|
CCDirector *pDirector = CCDirector::sharedDirector();
|
|
pDirector->setOpenGLView(m_pMainWnd);
|
|
|
|
// sets landscape mode
|
|
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
|
|
|
// turn on display FPS
|
|
pDirector->setDisplayFPS(true);
|
|
|
|
// set the ResourceEntry
|
|
CCFileUtils::setResourceEntry(&cocosTemplateResourceEntry);
|
|
|
|
// set the Images ResInfo (name and ResID)
|
|
CCFileUtils::setResourceInfo(ResInfo, sizeof(ResInfo) / sizeof(T_ResourceInfo));
|
|
|
|
// create a scene. it's an autorelease object
|
|
CCScene *pScene = HelloWorld::scene();
|
|
|
|
// run
|
|
CCDirector::sharedDirector()->runWithScene(pScene);
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
AppDelegate::AppDelegate()
|
|
:m_pMainWnd(NULL)
|
|
{
|
|
|
|
}
|
|
|
|
// 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()->stopAnimation();
|
|
|
|
// if you use SimpleAudioEngine, it must be pause
|
|
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
|
|
}
|
|
|
|
// this function will be called when the app is active again
|
|
void AppDelegate::applicationWillEnterForeground()
|
|
{
|
|
CCDirector::sharedDirector()->startAnimation();
|
|
|
|
// if you use SimpleAudioEngine, it must resume here
|
|
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
|
|
}
|