2010-11-12 16:25:14 +08:00
|
|
|
#include "AppDelegate.h"
|
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "tests/controller.h"
|
|
|
|
|
|
|
|
using namespace cocos2d;
|
|
|
|
|
|
|
|
// static void TimerCallback1(Int32 nTimerId, UInt32 uUserData);
|
|
|
|
AppDelegate::AppDelegate()
|
|
|
|
:m_pMainWnd(NULL)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
AppDelegate::~AppDelegate()
|
|
|
|
{
|
2010-11-27 18:25:31 +08:00
|
|
|
#if defined(CCX_PLATFORM_WIN32)
|
|
|
|
CCX_SAFE_DELETE(m_pMainWnd);
|
|
|
|
#endif
|
2010-11-12 16:25:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AppDelegate::applicationDidFinishLaunching()
|
|
|
|
{
|
|
|
|
// init the window
|
|
|
|
#if defined(CCX_PLATFORM_UPHONE)
|
|
|
|
if (!(m_pMainWnd = new CCXEGLView(this)) ||
|
|
|
|
! m_pMainWnd->Create(&TRectangle(0,0,GetScreenWidth(),GetScreenHeight())))
|
|
|
|
#elif defined(CCX_PLATFORM_WIN32)
|
|
|
|
if (!(m_pMainWnd = new CCXEGLView()) ||
|
|
|
|
! m_pMainWnd->Create(L"cocos2d-win32", 320, 480) )
|
2010-11-18 14:50:28 +08:00
|
|
|
#elif defined(CCX_PLATFORM_IPHONE)
|
2010-11-29 15:57:53 +08:00
|
|
|
if (!(m_pMainWnd = new CCXEGLView()))
|
2010-11-29 15:08:21 +08:00
|
|
|
#elif defined(CCX_PLATFORM_ANDROID)
|
2010-11-29 15:57:53 +08:00
|
|
|
if (!(m_pMainWnd = CCDirector::sharedDirector()->getOpenGLView()))
|
2010-11-12 16:25:14 +08:00
|
|
|
#else
|
|
|
|
#error
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
CCX_SAFE_DELETE(m_pMainWnd);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// init director
|
|
|
|
CCDirector * pDirector = CCDirector::sharedDirector();
|
|
|
|
pDirector->setOpenGLView(m_pMainWnd);
|
|
|
|
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
|
|
|
// pDirector->setDeviceOrientation(kCCDeviceOrientationPortrait);
|
2010-11-19 11:14:19 +08:00
|
|
|
pDirector->setDisplayFPS(true);
|
2010-11-29 15:57:53 +08:00
|
|
|
|
2011-01-19 18:02:35 +08:00
|
|
|
#if defined(CCX_PLATFORM_ANDROID)
|
2010-12-06 09:51:21 +08:00
|
|
|
CCFileUtils::setRelativePath("assets");
|
2010-11-12 16:25:14 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
CCScene * pScene = CCScene::node();
|
|
|
|
CCLayer * pLayer = new TestController();
|
|
|
|
pLayer->autorelease();
|
|
|
|
|
|
|
|
pScene->addChild(pLayer);
|
|
|
|
pDirector->runWithScene(pScene);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppDelegate::applicationDidEnterBackground()
|
|
|
|
{
|
2010-12-02 18:44:13 +08:00
|
|
|
CCDirector::sharedDirector()->pause();
|
2010-11-12 16:25:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AppDelegate::applicationWillEnterForeground()
|
|
|
|
{
|
2010-12-02 18:44:13 +08:00
|
|
|
CCDirector::sharedDirector()->resume();
|
2010-11-12 16:25:14 +08:00
|
|
|
}
|