mirror of https://github.com/axmolengine/axmol.git
110 lines
2.5 KiB
C++
110 lines
2.5 KiB
C++
// Application application cpp file.
|
|
|
|
// Original file name: test_uphoneApp.cpp
|
|
// Generated by TOPS Builder:Project wizard,Date:2010-7-26
|
|
|
|
|
|
#include "test_uphoneApp.h"
|
|
#include "test_uphoneMainForm.h"
|
|
|
|
#include "CCDirector.h"
|
|
#include "CCScene.h"
|
|
#include "CCSprite.h"
|
|
#include "tests/controller.h"
|
|
#include "CCTextureCache.h"
|
|
|
|
using namespace cocos2d;
|
|
|
|
static void TimerCallback1(Int32 nTimerId, UInt32 uUserData);
|
|
|
|
Ttest_uphoneApp::Ttest_uphoneApp()
|
|
: m_pMainWnd(NULL)
|
|
, m_nTimer(0)
|
|
{
|
|
|
|
}
|
|
|
|
Ttest_uphoneApp::~Ttest_uphoneApp()
|
|
{
|
|
|
|
}
|
|
|
|
bool Ttest_uphoneApp::initCocos2d()
|
|
{
|
|
// init director
|
|
CCDirector * pDirector = CCDirector::getSharedDirector();
|
|
pDirector->setOpenGLView(m_pMainWnd);
|
|
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
|
pDirector->setDisplayFPS(true);
|
|
|
|
// load background image texture and get window size
|
|
CCTexture2D * pTexture = CCTextureCache::sharedTextureCache()->addImage("/NEWPLUS/TDA_DATA/UserData/HelloWorld.png");
|
|
CGSize size = CCDirector::getSharedDirector()->getWinSize();
|
|
|
|
// create sprite instance
|
|
CCSprite * pSprite = (new CCSprite())->initWithTexture(pTexture);
|
|
pSprite->setPosition(CGPoint(size.width / 2, size.height / 2));
|
|
pSprite->autorelease()->retain();
|
|
|
|
// create layer instance
|
|
CCLayer * pLayer = new CCLayer();
|
|
pLayer->addChild(pSprite)->autorelease();
|
|
|
|
// add layer to scene
|
|
CCScene * pScene = CCScene::node();
|
|
pScene->addChild(pLayer);
|
|
|
|
// add scene to director
|
|
CCDirector::getSharedDirector()->runWithScene(pScene);
|
|
|
|
m_nTimer = TIMER_Create(3000, TIMER_MODE_NORMAL, TimerCallback1, 0, 0);
|
|
TIMER_Start(m_nTimer, 0);
|
|
|
|
return true;
|
|
}
|
|
|
|
Boolean Ttest_uphoneApp::EventHandler(EventType* pEvent)
|
|
{
|
|
Boolean bHandled = FALSE;
|
|
|
|
switch(pEvent->eType)
|
|
{
|
|
case EVENT_AppLoad:
|
|
{
|
|
m_pMainWnd = new TMainForm(this);
|
|
if (m_pMainWnd)
|
|
{
|
|
SetActiveWindow(m_pMainWnd);
|
|
}
|
|
else
|
|
{ // ´°¿Ú´´½¨Ê§°Ü£¬Í˳öÓ¦Óá£
|
|
SendStopEvent();
|
|
}
|
|
}
|
|
break;
|
|
|
|
case EVENT_AppStopNotify:
|
|
{
|
|
|
|
}
|
|
bHandled = FALSE;
|
|
break;
|
|
}
|
|
if (FALSE == bHandled)
|
|
{
|
|
return CCXApplication::EventHandler(pEvent);
|
|
}
|
|
|
|
return bHandled;
|
|
}
|
|
|
|
static void TimerCallback1(Int32 nTimerId, UInt32 uUserData)
|
|
{
|
|
CCScene * pScene = CCScene::node();
|
|
CCLayer * pLayer = new TestController();
|
|
pLayer->autorelease();
|
|
|
|
pScene->addChild(pLayer);
|
|
CCDirector::getSharedDirector()->replaceScene(pScene);
|
|
}
|