mirror of https://github.com/axmolengine/axmol.git
parent
ff3d907846
commit
c0705de149
|
@ -513,6 +513,18 @@
|
|||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="SceneTest"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\tests\SceneTest\SceneTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\tests\SceneTest\SceneTest.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\test_uphoneUnicodeScript.h"
|
||||
|
|
|
@ -0,0 +1,181 @@
|
|||
#include "SceneTest.h"
|
||||
#include "../testResource.h"
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// SceneTestLayer1
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
enum
|
||||
{
|
||||
MID_PUSHSCENE = 100,
|
||||
MID_PUSHSCENETRAN,
|
||||
MID_QUIT,
|
||||
MID_REPLACESCENE,
|
||||
MID_REPLACESCENETRAN,
|
||||
MID_GOBACK
|
||||
};
|
||||
|
||||
SceneTestLayer1::SceneTestLayer1()
|
||||
{
|
||||
CCMenuItemFont* item1 = CCMenuItemFont::itemFromString( "Test pushScene", this, menu_selector(SceneTestLayer1::onPushScene) );
|
||||
CCMenuItemFont* item2 = CCMenuItemFont::itemFromString( "Test pushScene w/transition", this, menu_selector(SceneTestLayer1::onPushSceneTran) );
|
||||
CCMenuItemFont* item3 = CCMenuItemFont::itemFromString( "Quit", this, menu_selector(SceneTestLayer1::onQuit) );
|
||||
|
||||
CCMenu* menu = CCMenu::menuWithItems( item1, item2, item3, NULL );
|
||||
menu->alignItemsVertically();
|
||||
|
||||
addChild( menu );
|
||||
|
||||
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
||||
CCSprite* sprite = CCSprite::spriteWithFile(s_pPathGrossini);
|
||||
addChild(sprite);
|
||||
sprite->setPosition( CGPointMake(s.width-40, s.height/2) );
|
||||
CCIntervalAction* rotate = CCRotateBy::actionWithDuration(2, 360);
|
||||
CCAction* repeat = CCRepeatForever::actionWithAction(rotate);
|
||||
sprite->runAction(repeat);
|
||||
|
||||
schedule( schedule_selector(SceneTestLayer1::testDealloc) );
|
||||
}
|
||||
|
||||
void SceneTestLayer1::testDealloc(ccTime dt)
|
||||
{
|
||||
//UXLOG("SceneTestLayer1:testDealloc");
|
||||
}
|
||||
|
||||
SceneTestLayer1::~SceneTestLayer1()
|
||||
{
|
||||
//NSLog(@"SceneTestLayer1 - dealloc");
|
||||
}
|
||||
|
||||
void SceneTestLayer1::onPushScene(NSObject* pSender)
|
||||
{
|
||||
CCScene* scene = new SceneTestScene();
|
||||
CCLayer* pLayer = new SceneTestLayer2();
|
||||
scene->addChild( pLayer, 0 );
|
||||
CCDirector::getSharedDirector()->pushScene( scene );
|
||||
}
|
||||
|
||||
void SceneTestLayer1::onPushSceneTran(NSObject* pSender)
|
||||
{
|
||||
CCScene* scene = new SceneTestScene();
|
||||
CCLayer* pLayer = new SceneTestLayer2();
|
||||
scene->addChild( pLayer, 0 );
|
||||
|
||||
CCDirector::getSharedDirector()->pushScene( CCSlideInTTransition::transitionWithDuration(1, scene) );
|
||||
}
|
||||
|
||||
|
||||
void SceneTestLayer1::onQuit(NSObject* pSender)
|
||||
{
|
||||
//getCocosApp()->exit();
|
||||
//CCDirector::getSharedDirector()->popScene();
|
||||
|
||||
//// HA HA... no more terminate on sdk v3.0
|
||||
//// http://developer.apple.com/iphone/library/qa/qa2008/qa1561.html
|
||||
//if( [[UIApplication sharedApplication] respondsToSelector:@selector(terminate)] )
|
||||
// [[UIApplication sharedApplication] performSelector:@selector(terminate)];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// SceneTestLayer2
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
SceneTestLayer2::SceneTestLayer2()
|
||||
{
|
||||
m_timeCounter = 0;
|
||||
|
||||
CCMenuItemFont* item1 = CCMenuItemFont::itemFromString( "replaceScene", this, menu_selector(SceneTestLayer2::onReplaceScene) );
|
||||
CCMenuItemFont* item2 = CCMenuItemFont::itemFromString( "replaceScene w/transition", this, menu_selector(SceneTestLayer2::onReplaceSceneTran) );
|
||||
CCMenuItemFont* item3 = CCMenuItemFont::itemFromString( "Go Back", this, menu_selector(SceneTestLayer2::onGoBack) );
|
||||
|
||||
CCMenu* menu = CCMenu::menuWithItems( item1, item2, item3, NULL );
|
||||
menu->alignItemsVertically();
|
||||
|
||||
addChild( menu );
|
||||
|
||||
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
||||
CCSprite* sprite = CCSprite::spriteWithFile(s_pPathGrossini);
|
||||
addChild(sprite);
|
||||
sprite->setPosition( CGPointMake(s.width-40, s.height/2) );
|
||||
CCIntervalAction* rotate = CCRotateBy::actionWithDuration(2, 360);
|
||||
CCAction* repeat = CCRepeatForever::actionWithAction(rotate);
|
||||
sprite->runAction(repeat);
|
||||
|
||||
schedule( schedule_selector(SceneTestLayer2::testDealloc) );
|
||||
}
|
||||
|
||||
void SceneTestLayer2::testDealloc(ccTime dt)
|
||||
{
|
||||
//m_timeCounter += dt;
|
||||
//if( m_timeCounter > 10 )
|
||||
// onReplaceScene(this);
|
||||
}
|
||||
|
||||
void SceneTestLayer2::onGoBack(NSObject* pSender)
|
||||
{
|
||||
CCDirector::getSharedDirector()->popScene();
|
||||
}
|
||||
|
||||
void SceneTestLayer2::onReplaceScene(NSObject* pSender)
|
||||
{
|
||||
CCScene* pScene = new SceneTestScene();
|
||||
CCLayer* pLayer = new SceneTestLayer3();
|
||||
pScene->addChild( pLayer, 0 );
|
||||
CCDirector::getSharedDirector()->replaceScene( pScene );
|
||||
}
|
||||
|
||||
|
||||
void SceneTestLayer2::onReplaceSceneTran(NSObject* pSender)
|
||||
{
|
||||
CCScene* pScene = new SceneTestScene();
|
||||
CCLayer* pLayer = new SceneTestLayer3();
|
||||
pScene->addChild( pLayer, 0 );
|
||||
CCDirector::getSharedDirector()->replaceScene( CCFlipXTransition::transitionWithDuration(2, pScene) );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// SceneTestLayer3
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
SceneTestLayer3::SceneTestLayer3()
|
||||
{
|
||||
setIsTouchEnabled( true );
|
||||
CCLabel* label = CCLabel::labelWithString("Touch to popScene", "Marker Felt", 28);
|
||||
addChild(label);
|
||||
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
||||
label->setPosition( CGPointMake(s.width/2, s.height/2) );
|
||||
|
||||
CCSprite* sprite = CCSprite::spriteWithFile(s_pPathGrossini);
|
||||
addChild(sprite);
|
||||
sprite->setPosition( CGPointMake(s.width-40, s.height/2) );
|
||||
CCIntervalAction* rotate = CCRotateBy::actionWithDuration(2, 360);
|
||||
CCAction* repeat = CCRepeatForever::actionWithAction(rotate);
|
||||
sprite->runAction(repeat);
|
||||
|
||||
//schedule();
|
||||
}
|
||||
|
||||
void SceneTestLayer3::testDealloc(ccTime dt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SceneTestLayer3::ccTouchesEnded(NSSet* touches, UIEvent* event)
|
||||
{
|
||||
static int i = 0;
|
||||
//UXLOG("SceneTestLayer3::ccTouchesEnded(%d)", ++i);
|
||||
CCDirector::getSharedDirector()->popScene();
|
||||
}
|
||||
|
||||
void SceneTestScene::runThisTest()
|
||||
{
|
||||
CCLayer* pLayer = new SceneTestLayer1();
|
||||
addChild(pLayer);
|
||||
|
||||
CCDirector::getSharedDirector()->replaceScene(this);
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
#ifndef _SCENE_TEST_H_
|
||||
#define _SCENE_TEST_H_
|
||||
|
||||
#include "cocos2d.h"
|
||||
#include "../testBasic.h"
|
||||
|
||||
class SceneTestLayer1 : public CCLayer
|
||||
{
|
||||
public:
|
||||
SceneTestLayer1();
|
||||
~SceneTestLayer1();
|
||||
|
||||
void testDealloc(ccTime dt);
|
||||
void onPushScene(NSObject* pSender);
|
||||
void onPushSceneTran(NSObject* pSender);
|
||||
void onQuit(NSObject* pSender);
|
||||
|
||||
//CREATE_NODE(SceneTestLayer1);
|
||||
} ;
|
||||
|
||||
class SceneTestLayer2 : public CCLayer
|
||||
{
|
||||
float m_timeCounter;
|
||||
public:
|
||||
SceneTestLayer2();
|
||||
|
||||
void testDealloc(ccTime dt);
|
||||
void onGoBack(NSObject* pSender);
|
||||
void onReplaceScene(NSObject* pSender);
|
||||
void onReplaceSceneTran(NSObject* pSender);
|
||||
|
||||
//CREATE_NODE(SceneTestLayer2);
|
||||
} ;
|
||||
|
||||
class SceneTestLayer3 : public CCColorLayer
|
||||
{
|
||||
public:
|
||||
SceneTestLayer3();
|
||||
|
||||
virtual void testDealloc(ccTime dt);
|
||||
|
||||
virtual void ccTouchesEnded(NSSet* touches, UIEvent* event);
|
||||
|
||||
//CREATE_NODE(SceneTestLayer3);
|
||||
} ;
|
||||
|
||||
class SceneTestScene : public TestScene
|
||||
{
|
||||
public:
|
||||
virtual void runThisTest();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -45,6 +45,8 @@ static TestScene* CreateTestScene(int nIdx)
|
|||
pScene = new ActionManagerTestScene(); break;
|
||||
case TEST_LAYER:
|
||||
pScene = new LayerTestScene(); break;
|
||||
case TEST_SCENE:
|
||||
pScene = new SceneTestScene(); break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "MenuTest/MenuTest.h"
|
||||
#include "ActionManagerTest/ActionManagerTest.h"
|
||||
#include "LayerTest/LayerTest.h"
|
||||
#include "SceneTest/SceneTest.h"
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -34,6 +35,7 @@ enum
|
|||
TEST_MENU,
|
||||
TEST_ACTION_MANAGER,
|
||||
TEST_LAYER,
|
||||
TEST_SCENE,
|
||||
TESTS_COUNT,
|
||||
};
|
||||
|
||||
|
@ -53,6 +55,7 @@ const std::string g_aTestNames[TESTS_COUNT] = {
|
|||
"MenuTest",
|
||||
"ActionManagerTest",
|
||||
"LayerTest",
|
||||
"SceneTest",
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue