This commit is contained in:
RongHong 2011-07-08 18:31:22 +08:00
commit 7b30969991
4 changed files with 30 additions and 17 deletions

View File

@ -1,8 +1,8 @@
#include "TouchesTest.h"
#include "Ball.h"
#include "Paddle.h"
#include "../testResource.h"
#include "TouchesTest.h"
#include "Ball.h"
#include "Paddle.h"
#include "../testResource.h"
enum tagPlayer
{
kHighPlayer,
@ -24,6 +24,7 @@ enum
//
//------------------------------------------------------------------
PongScene::PongScene()
:TestScene(true)
{
PongLayer *pongLayer = new PongLayer();//PongLayer::node();
addChild(pongLayer);

View File

@ -5,11 +5,6 @@
static CCPoint s_tCurPos = CCPointZero;
static void ChangeOrientation(ccDeviceOrientation eOrientation)
{
CCDirector::sharedDirector()->setDeviceOrientation(eOrientation);
}
static TestScene* CreateTestScene(int nIdx)
{
CCDirector::sharedDirector()->purgeCachedData();
@ -41,7 +36,6 @@ static TestScene* CreateTestScene(int nIdx)
case TEST_COCOSNODE:
pScene = new CocosNodeTestScene(); break;
case TEST_TOUCHES:
ChangeOrientation(CCDeviceOrientationLandscapeRight);
pScene = new PongScene(); break;
case TEST_MENU:
pScene = new MenuTestScene(); break;
@ -119,9 +113,6 @@ static TestScene* CreateTestScene(int nIdx)
TestController::TestController()
: m_tBeginPos(CCPointZero)
{
// change to default orientation
ChangeOrientation(CCDeviceOrientationPortrait);
// add close menu
CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage(s_pPathClose, s_pPathClose, this, menu_selector(TestController::closeCallback) );
CCMenu* pMenu =CCMenu::menuWithItems(pCloseItem, NULL);

View File

@ -29,8 +29,14 @@ void BackToMainMenuLayer::MainMenuCallback(CCObject* pSender)
CCDirector::sharedDirector()->replaceScene(pScene);
}
TestScene::TestScene()
TestScene::TestScene(bool bPortrait)
:m_bPortrait(bPortrait)
{
if (m_bPortrait)
{
CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationLandscapeRight);
}
CCScene::init();
CCLayer* pLayer = new BackToMainMenuLayer();
pLayer->autorelease();
@ -38,3 +44,14 @@ TestScene::TestScene()
// 54321 is the tag of BackToMainMenuLayer
addChild(pLayer, 1000, 54321);
}
void TestScene::onExit()
{
if (m_bPortrait)
{
// turn back to the default orientation
CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationPortrait);
}
CCScene::onExit();
}

View File

@ -16,10 +16,14 @@ public:
class TestScene : public CCScene
{
public:
TestScene();
public:
TestScene(bool bPortrait = false);
virtual void runThisTest() = 0;
virtual void onExit();
protected:
bool m_bPortrait; // indicate if this test case requires portrait mode
};
#endif