mirror of https://github.com/axmolengine/axmol.git
commit
1a25dd83a5
|
@ -218,3 +218,9 @@ void DirectorTestScene::runThisTest()
|
||||||
|
|
||||||
CCDirector::sharedDirector()->replaceScene(this);
|
CCDirector::sharedDirector()->replaceScene(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DirectorTestScene::MainMenuCallback(CCObject* pSender)
|
||||||
|
{
|
||||||
|
CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationPortrait);
|
||||||
|
TestScene::MainMenuCallback(pSender);
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@ class DirectorTestScene : public TestScene
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void runThisTest();
|
virtual void runThisTest();
|
||||||
|
|
||||||
|
virtual void MainMenuCallback(CCObject* pSender);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -52,25 +52,6 @@ CCLayer* backHiResAction()
|
||||||
return pLayer;
|
return pLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// HiResTestBackToMainMenuLayer
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
class HiResTestBackToainMenuLayer : public BackToMainMenuLayer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
HiResTestBackToainMenuLayer() {}
|
|
||||||
|
|
||||||
// The CallBack for back to the main menu scene
|
|
||||||
virtual void MainMenuCallback(CCObject* pSender)
|
|
||||||
{
|
|
||||||
CCDirector::sharedDirector()->enableRetinaDisplay(sm_bRitinaDisplay);
|
|
||||||
BackToMainMenuLayer::MainMenuCallback(pSender);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool sm_bRitinaDisplay;
|
|
||||||
};
|
|
||||||
bool HiResTestBackToainMenuLayer::sm_bRitinaDisplay = false;
|
|
||||||
|
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
//
|
//
|
||||||
// HiResDemo
|
// HiResDemo
|
||||||
|
@ -222,9 +203,11 @@ std::string HiResTest2::subtitle()
|
||||||
// HiResTestScene
|
// HiResTestScene
|
||||||
//
|
//
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
|
bool HiResTestScene::sm_bRitinaDisplay = false;
|
||||||
|
|
||||||
void HiResTestScene::runThisTest()
|
void HiResTestScene::runThisTest()
|
||||||
{
|
{
|
||||||
HiResTestBackToainMenuLayer::sm_bRitinaDisplay = CCDirector::sharedDirector()->isRetinaDisplay();
|
sm_bRitinaDisplay = CCDirector::sharedDirector()->isRetinaDisplay();
|
||||||
|
|
||||||
CCLayer* pLayer = nextHiResAction();
|
CCLayer* pLayer = nextHiResAction();
|
||||||
addChild(pLayer);
|
addChild(pLayer);
|
||||||
|
@ -233,13 +216,8 @@ void HiResTestScene::runThisTest()
|
||||||
CCDirector::sharedDirector()->replaceScene(this);
|
CCDirector::sharedDirector()->replaceScene(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HiResTestScene::onEnter()
|
void HiResTestScene::MainMenuCallback(CCObject* pSender)
|
||||||
{
|
{
|
||||||
TestScene::onEnter();
|
CCDirector::sharedDirector()->enableRetinaDisplay(sm_bRitinaDisplay);
|
||||||
|
TestScene::MainMenuCallback(pSender);
|
||||||
CCLayer* pLayer = (CCLayer*)getChildByTag(54321);
|
|
||||||
removeChild(pLayer, true);
|
|
||||||
pLayer = new HiResTestBackToainMenuLayer;
|
|
||||||
addChild(pLayer, 1000, 54321);
|
|
||||||
pLayer->release();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,9 @@ class HiResTestScene : public TestScene
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void runThisTest();
|
virtual void runThisTest();
|
||||||
virtual void onEnter();
|
virtual void MainMenuCallback(CCObject* pSender);
|
||||||
|
|
||||||
|
static bool sm_bRitinaDisplay;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -31,9 +31,10 @@ PongScene::PongScene()
|
||||||
pongLayer->release();
|
pongLayer->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PongScene::onExit()
|
void PongScene::MainMenuCallback(CCObject* pSender)
|
||||||
{
|
{
|
||||||
TestScene::onExit();
|
CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationPortrait);
|
||||||
|
TestScene::MainMenuCallback(pSender);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
|
@ -11,8 +11,9 @@ class PongScene : public TestScene
|
||||||
public:
|
public:
|
||||||
PongScene();
|
PongScene();
|
||||||
|
|
||||||
virtual void onExit();
|
|
||||||
virtual void runThisTest();
|
virtual void runThisTest();
|
||||||
|
|
||||||
|
virtual void MainMenuCallback(CCObject* pSender);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Ball;
|
class Ball;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
#include "testResource.h"
|
#include "testResource.h"
|
||||||
|
#include "tests.h"
|
||||||
|
|
||||||
#define LINE_SPACE 40
|
#define LINE_SPACE 40
|
||||||
|
|
||||||
|
@ -113,8 +114,6 @@ static TestScene* CreateTestScene(int nIdx)
|
||||||
TestController::TestController()
|
TestController::TestController()
|
||||||
: m_tBeginPos(CCPointZero)
|
: m_tBeginPos(CCPointZero)
|
||||||
{
|
{
|
||||||
//CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationPortrait);
|
|
||||||
|
|
||||||
// add close menu
|
// add close menu
|
||||||
CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage(s_pPathClose, s_pPathClose, this, menu_selector(TestController::closeCallback) );
|
CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage(s_pPathClose, s_pPathClose, this, menu_selector(TestController::closeCallback) );
|
||||||
CCMenu* pMenu =CCMenu::menuWithItems(pCloseItem, NULL);
|
CCMenu* pMenu =CCMenu::menuWithItems(pCloseItem, NULL);
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#define _CONTROLLER_H_
|
#define _CONTROLLER_H_
|
||||||
|
|
||||||
#include "cocos2d.h"
|
#include "cocos2d.h"
|
||||||
#include "tests.h"
|
|
||||||
|
|
||||||
using namespace cocos2d;
|
using namespace cocos2d;
|
||||||
|
|
||||||
|
|
|
@ -1,34 +1,6 @@
|
||||||
#include "testBasic.h"
|
#include "testBasic.h"
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
|
|
||||||
BackToMainMenuLayer::BackToMainMenuLayer()
|
|
||||||
{
|
|
||||||
//add the menu item for back to main menu
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_AIRPLAY)
|
|
||||||
CCLabelBMFont* label = CCLabelBMFont::bitmapFontAtlasWithString("MainMenu", "fonts/arial16.fnt");
|
|
||||||
#else
|
|
||||||
CCLabelTTF* label = CCLabelTTF::labelWithString("MainMenu", "Arial", 20);
|
|
||||||
#endif
|
|
||||||
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(BackToMainMenuLayer::MainMenuCallback));
|
|
||||||
|
|
||||||
CCMenu* pMenu =CCMenu::menuWithItems(pMenuItem, NULL);
|
|
||||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
||||||
pMenu->setPosition( CCPointZero );
|
|
||||||
pMenuItem->setPosition( CCPointMake( s.width - 50, 25) );
|
|
||||||
|
|
||||||
addChild(pMenu, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BackToMainMenuLayer::MainMenuCallback(CCObject* pSender)
|
|
||||||
{
|
|
||||||
CCScene* pScene = CCScene::node();
|
|
||||||
CCLayer* pLayer = new TestController();
|
|
||||||
pLayer->autorelease();
|
|
||||||
|
|
||||||
pScene->addChild(pLayer);
|
|
||||||
CCDirector::sharedDirector()->replaceScene(pScene);
|
|
||||||
}
|
|
||||||
|
|
||||||
TestScene::TestScene(bool bPortrait)
|
TestScene::TestScene(bool bPortrait)
|
||||||
:m_bPortrait(bPortrait)
|
:m_bPortrait(bPortrait)
|
||||||
{
|
{
|
||||||
|
@ -38,9 +10,34 @@ TestScene::TestScene(bool bPortrait)
|
||||||
}
|
}
|
||||||
|
|
||||||
CCScene::init();
|
CCScene::init();
|
||||||
CCLayer* pLayer = new BackToMainMenuLayer();
|
}
|
||||||
|
|
||||||
|
void TestScene::onEnter()
|
||||||
|
{
|
||||||
|
CCScene::onEnter();
|
||||||
|
|
||||||
|
//add the menu item for back to main menu
|
||||||
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_AIRPLAY)
|
||||||
|
CCLabelBMFont* label = CCLabelBMFont::bitmapFontAtlasWithString("MainMenu", "fonts/arial16.fnt");
|
||||||
|
#else
|
||||||
|
CCLabelTTF* label = CCLabelTTF::labelWithString("MainMenu", "Arial", 20);
|
||||||
|
#endif
|
||||||
|
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(TestScene::MainMenuCallback));
|
||||||
|
|
||||||
|
CCMenu* pMenu =CCMenu::menuWithItems(pMenuItem, NULL);
|
||||||
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||||
|
pMenu->setPosition( CCPointZero );
|
||||||
|
pMenuItem->setPosition( CCPointMake( s.width - 50, 25) );
|
||||||
|
|
||||||
|
addChild(pMenu, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestScene::MainMenuCallback(CCObject* pSender)
|
||||||
|
{
|
||||||
|
CCScene* pScene = CCScene::node();
|
||||||
|
CCLayer* pLayer = new TestController();
|
||||||
pLayer->autorelease();
|
pLayer->autorelease();
|
||||||
|
|
||||||
// 54321 is the tag of BackToMainMenuLayer
|
pScene->addChild(pLayer);
|
||||||
addChild(pLayer, 1000, 54321);
|
CCDirector::sharedDirector()->replaceScene(pScene);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,22 +5,17 @@
|
||||||
|
|
||||||
using namespace cocos2d;
|
using namespace cocos2d;
|
||||||
|
|
||||||
class BackToMainMenuLayer : public CCLayer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BackToMainMenuLayer();
|
|
||||||
|
|
||||||
// The CallBack for back to the main menu scene
|
|
||||||
virtual void MainMenuCallback(CCObject* pSender);
|
|
||||||
};
|
|
||||||
|
|
||||||
class TestScene : public CCScene
|
class TestScene : public CCScene
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestScene(bool bPortrait = false);
|
TestScene(bool bPortrait = false);
|
||||||
|
virtual void onEnter();
|
||||||
|
|
||||||
virtual void runThisTest() = 0;
|
virtual void runThisTest() = 0;
|
||||||
|
|
||||||
|
// The CallBack for back to the main menu scene
|
||||||
|
virtual void MainMenuCallback(CCObject* pSender);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_bPortrait; // indicate if this test case requires portrait mode
|
bool m_bPortrait; // indicate if this test case requires portrait mode
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue