2010-07-26 17:12:06 +08:00
|
|
|
|
// 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"
|
2010-08-03 11:23:12 +08:00
|
|
|
|
|
|
|
|
|
#include "CCDirector.h"
|
2010-08-06 17:50:20 +08:00
|
|
|
|
#include "CCScene.h"
|
2010-08-17 15:01:09 +08:00
|
|
|
|
#include "CCSprite.h"
|
2010-08-06 17:50:20 +08:00
|
|
|
|
#include "tests/controller.h"
|
2010-08-17 15:01:09 +08:00
|
|
|
|
#include "CCTextureCache.h"
|
2010-08-03 11:23:12 +08:00
|
|
|
|
|
2010-08-05 10:29:29 +08:00
|
|
|
|
using namespace cocos2d;
|
|
|
|
|
|
2010-08-17 15:01:09 +08:00
|
|
|
|
static void TimerCallback1(Int32 nTimerId, UInt32 uUserData);
|
|
|
|
|
|
2010-07-26 17:12:06 +08:00
|
|
|
|
Ttest_uphoneApp::Ttest_uphoneApp()
|
2010-08-03 11:23:12 +08:00
|
|
|
|
: m_pMainWnd(NULL)
|
2010-08-17 15:01:09 +08:00
|
|
|
|
, m_nTimer(0)
|
2010-07-26 17:12:06 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ttest_uphoneApp::~Ttest_uphoneApp()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-06 17:50:20 +08:00
|
|
|
|
bool Ttest_uphoneApp::initCocos2d()
|
2010-08-03 11:23:12 +08:00
|
|
|
|
{
|
2010-08-17 15:01:09 +08:00
|
|
|
|
// init director
|
2010-08-03 11:23:12 +08:00
|
|
|
|
CCDirector::getSharedDirector()->setOpenGLView(m_pMainWnd);
|
2010-08-11 15:19:47 +08:00
|
|
|
|
CCDirector::getSharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
2010-08-06 17:50:20 +08:00
|
|
|
|
|
2010-08-17 15:01:09 +08:00
|
|
|
|
// 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();
|
2010-08-06 17:50:20 +08:00
|
|
|
|
|
2010-08-17 15:01:09 +08:00
|
|
|
|
// add layer to scene
|
|
|
|
|
CCScene * pScene = CCScene::node();
|
2010-08-06 17:50:20 +08:00
|
|
|
|
pScene->addChild(pLayer);
|
2010-08-17 15:01:09 +08:00
|
|
|
|
|
|
|
|
|
// add scene to director
|
2010-08-06 17:50:20 +08:00
|
|
|
|
CCDirector::getSharedDirector()->runWithScene(pScene);
|
|
|
|
|
|
2010-08-17 15:01:09 +08:00
|
|
|
|
m_nTimer = TIMER_Create(3000, TIMER_MODE_NORMAL, TimerCallback1, 0, 0);
|
|
|
|
|
TIMER_Start(m_nTimer, 0);
|
|
|
|
|
|
2010-08-06 17:50:20 +08:00
|
|
|
|
return true;
|
2010-08-03 11:23:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2010-07-26 17:12:06 +08:00
|
|
|
|
Boolean Ttest_uphoneApp::EventHandler(EventType* pEvent)
|
|
|
|
|
{
|
|
|
|
|
Boolean bHandled = FALSE;
|
|
|
|
|
|
|
|
|
|
switch(pEvent->eType)
|
|
|
|
|
{
|
|
|
|
|
case EVENT_AppLoad:
|
|
|
|
|
{
|
2010-08-03 11:23:12 +08:00
|
|
|
|
m_pMainWnd = new TMainForm(this);
|
|
|
|
|
if (m_pMainWnd)
|
2010-07-26 17:12:06 +08:00
|
|
|
|
{
|
2010-08-03 11:23:12 +08:00
|
|
|
|
SetActiveWindow(m_pMainWnd);
|
2010-07-26 17:12:06 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{ // <20><><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3>˳<EFBFBD>Ӧ<EFBFBD>á<EFBFBD>
|
|
|
|
|
SendStopEvent();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EVENT_AppStopNotify:
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
bHandled = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (FALSE == bHandled)
|
|
|
|
|
{
|
2010-08-03 11:23:12 +08:00
|
|
|
|
return CCXApplication::EventHandler(pEvent);
|
2010-07-26 17:12:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bHandled;
|
|
|
|
|
}
|
2010-08-17 15:01:09 +08:00
|
|
|
|
|
|
|
|
|
static void TimerCallback1(Int32 nTimerId, UInt32 uUserData)
|
|
|
|
|
{
|
2010-08-17 17:38:26 +08:00
|
|
|
|
CCScene * pScene = CCScene::node();
|
|
|
|
|
CCLayer * pLayer = new TestController();
|
|
|
|
|
pLayer->autorelease();
|
2010-08-17 15:01:09 +08:00
|
|
|
|
|
2010-08-17 17:38:26 +08:00
|
|
|
|
pScene->addChild(pLayer);
|
|
|
|
|
CCDirector::getSharedDirector()->replaceScene(pScene);
|
2010-08-17 15:01:09 +08:00
|
|
|
|
}
|