mirror of https://github.com/axmolengine/axmol.git
fixed #599, Resolve the wrong orientation when exit the TouchesTest.
This commit is contained in:
parent
9755ff59aa
commit
8ad7236ca2
|
@ -218,3 +218,9 @@ void DirectorTestScene::runThisTest()
|
|||
|
||||
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:
|
||||
virtual void runThisTest();
|
||||
|
||||
virtual void MainMenuCallback(CCObject* pSender);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -52,25 +52,6 @@ CCLayer* backHiResAction()
|
|||
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
|
||||
|
@ -222,9 +203,11 @@ std::string HiResTest2::subtitle()
|
|||
// HiResTestScene
|
||||
//
|
||||
///////////////////////////////////
|
||||
bool HiResTestScene::sm_bRitinaDisplay = false;
|
||||
|
||||
void HiResTestScene::runThisTest()
|
||||
{
|
||||
HiResTestBackToainMenuLayer::sm_bRitinaDisplay = CCDirector::sharedDirector()->isRetinaDisplay();
|
||||
sm_bRitinaDisplay = CCDirector::sharedDirector()->isRetinaDisplay();
|
||||
|
||||
CCLayer* pLayer = nextHiResAction();
|
||||
addChild(pLayer);
|
||||
|
@ -233,13 +216,8 @@ void HiResTestScene::runThisTest()
|
|||
CCDirector::sharedDirector()->replaceScene(this);
|
||||
}
|
||||
|
||||
void HiResTestScene::onEnter()
|
||||
void HiResTestScene::MainMenuCallback(CCObject* pSender)
|
||||
{
|
||||
TestScene::onEnter();
|
||||
|
||||
CCLayer* pLayer = (CCLayer*)getChildByTag(54321);
|
||||
removeChild(pLayer, true);
|
||||
pLayer = new HiResTestBackToainMenuLayer;
|
||||
addChild(pLayer, 1000, 54321);
|
||||
pLayer->release();
|
||||
CCDirector::sharedDirector()->enableRetinaDisplay(sm_bRitinaDisplay);
|
||||
TestScene::MainMenuCallback(pSender);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,9 @@ class HiResTestScene : public TestScene
|
|||
{
|
||||
public:
|
||||
virtual void runThisTest();
|
||||
virtual void onEnter();
|
||||
virtual void MainMenuCallback(CCObject* pSender);
|
||||
|
||||
static bool sm_bRitinaDisplay;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,9 +31,10 @@ PongScene::PongScene()
|
|||
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:
|
||||
PongScene();
|
||||
|
||||
virtual void onExit();
|
||||
virtual void runThisTest();
|
||||
|
||||
virtual void MainMenuCallback(CCObject* pSender);
|
||||
};
|
||||
|
||||
class Ball;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "controller.h"
|
||||
#include "testResource.h"
|
||||
#include "tests.h"
|
||||
|
||||
#define LINE_SPACE 40
|
||||
|
||||
|
@ -113,8 +114,6 @@ static TestScene* CreateTestScene(int nIdx)
|
|||
TestController::TestController()
|
||||
: m_tBeginPos(CCPointZero)
|
||||
{
|
||||
CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationPortrait);
|
||||
|
||||
// add close menu
|
||||
CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage(s_pPathClose, s_pPathClose, this, menu_selector(TestController::closeCallback) );
|
||||
CCMenu* pMenu =CCMenu::menuWithItems(pCloseItem, NULL);
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#define _CONTROLLER_H_
|
||||
|
||||
#include "cocos2d.h"
|
||||
#include "tests.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
|
||||
|
|
|
@ -1,34 +1,6 @@
|
|||
#include "testBasic.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)
|
||||
:m_bPortrait(bPortrait)
|
||||
{
|
||||
|
@ -38,9 +10,34 @@ TestScene::TestScene(bool bPortrait)
|
|||
}
|
||||
|
||||
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();
|
||||
|
||||
// 54321 is the tag of BackToMainMenuLayer
|
||||
addChild(pLayer, 1000, 54321);
|
||||
pScene->addChild(pLayer);
|
||||
CCDirector::sharedDirector()->replaceScene(pScene);
|
||||
}
|
||||
|
|
|
@ -5,22 +5,17 @@
|
|||
|
||||
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
|
||||
{
|
||||
public:
|
||||
TestScene(bool bPortrait = false);
|
||||
virtual void onEnter();
|
||||
|
||||
virtual void runThisTest() = 0;
|
||||
|
||||
// The CallBack for back to the main menu scene
|
||||
virtual void MainMenuCallback(CCObject* pSender);
|
||||
|
||||
protected:
|
||||
bool m_bPortrait; // indicate if this test case requires portrait mode
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue