2010-10-02 09:14:30 +08:00
|
|
|
// 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"
|
2010-10-11 15:28:58 +08:00
|
|
|
#include "Resource.h"
|
2010-10-02 09:14:30 +08:00
|
|
|
|
|
|
|
using namespace cocos2d;
|
|
|
|
|
2010-10-11 15:28:58 +08:00
|
|
|
extern const AppResourceEntry cocosTemplateResourceEntry;
|
|
|
|
|
2010-11-11 11:18:58 +08:00
|
|
|
bool AppDelegate::applicationDidFinishLaunching()
|
2010-10-02 09:14:30 +08:00
|
|
|
{
|
2010-11-11 11:18:58 +08:00
|
|
|
// init the window
|
2010-11-12 16:25:14 +08:00
|
|
|
if (!(m_pMainWnd = new CCXEGLView(this)) ||
|
|
|
|
! m_pMainWnd->Create(&TRectangle(0,0,GetScreenWidth(),GetScreenHeight())))
|
2010-11-11 11:18:58 +08:00
|
|
|
{
|
|
|
|
delete m_pMainWnd;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-10-02 09:14:30 +08:00
|
|
|
// init director
|
2010-11-11 11:18:58 +08:00
|
|
|
CCDirector *pDirector = CCDirector::sharedDirector();
|
2010-10-02 09:14:30 +08:00
|
|
|
pDirector->setOpenGLView(m_pMainWnd);
|
|
|
|
|
|
|
|
// sets landscape mode
|
|
|
|
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
|
|
|
|
|
|
|
// turn on display FPS
|
|
|
|
pDirector->setDisplayFPS(true);
|
|
|
|
|
2010-10-11 15:28:58 +08:00
|
|
|
// set the ResourceEntry
|
2010-10-19 17:12:16 +08:00
|
|
|
CCFileUtils::setResourceEntry(&cocosTemplateResourceEntry);
|
2010-10-11 15:28:58 +08:00
|
|
|
|
2010-10-12 11:52:11 +08:00
|
|
|
// set the Images ResInfo (name and ResID)
|
2010-10-19 17:12:16 +08:00
|
|
|
CCFileUtils::setResourceInfo(ResInfo, sizeof(ResInfo) / sizeof(T_ResourceInfo));
|
2010-10-11 15:28:58 +08:00
|
|
|
|
2010-10-02 09:14:30 +08:00
|
|
|
// create a scene. it's an autorelease object
|
|
|
|
CCScene *pScene = HelloWorld::scene();
|
|
|
|
|
|
|
|
// run
|
2010-11-11 11:18:58 +08:00
|
|
|
CCDirector::sharedDirector()->runWithScene(pScene);
|
2010-10-02 09:14:30 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AppDelegate::AppDelegate()
|
2010-11-12 16:25:14 +08:00
|
|
|
:m_pMainWnd(NULL)
|
2010-10-02 09:14:30 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-10-29 14:48:00 +08:00
|
|
|
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
|
2010-10-27 16:25:02 +08:00
|
|
|
void AppDelegate::applicationDidEnterBackground()
|
|
|
|
{
|
2010-11-11 11:18:58 +08:00
|
|
|
CCDirector::sharedDirector()->stopAnimation();
|
2010-10-29 14:48:00 +08:00
|
|
|
|
|
|
|
// if you use SimpleAudioEngine, it must be pause
|
|
|
|
// SimpleAudioEngine::getSharedEngine()->pauseBackgroundMusic();
|
2010-10-27 16:25:02 +08:00
|
|
|
}
|
|
|
|
|
2010-10-29 14:48:00 +08:00
|
|
|
// this function will be called when the app is active again
|
2010-10-27 16:25:02 +08:00
|
|
|
void AppDelegate::applicationWillEnterForeground()
|
|
|
|
{
|
2010-11-11 11:18:58 +08:00
|
|
|
CCDirector::sharedDirector()->startAnimation();
|
2010-10-29 14:48:00 +08:00
|
|
|
|
2010-11-11 11:18:58 +08:00
|
|
|
// if you use SimpleAudioEngine, it must resume here
|
2010-10-29 14:48:00 +08:00
|
|
|
// SimpleAudioEngine::getSharedEngine()->resumeBackgroundMusic();
|
2010-10-27 16:25:02 +08:00
|
|
|
}
|