From e723a424d88dae4f15664298f4692fd94db455a5 Mon Sep 17 00:00:00 2001 From: yangws Date: Tue, 3 May 2011 11:37:30 +0800 Subject: [PATCH] Modify tests doesn't change orientation every test scene. --- tests/AppDelegate.cpp | 1 + tests/tests/controller.cpp | 21 ++++++++++++++++----- tests/tests/controller.h | 1 - 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/AppDelegate.cpp b/tests/AppDelegate.cpp index e61761a209..a4bf309764 100644 --- a/tests/AppDelegate.cpp +++ b/tests/AppDelegate.cpp @@ -70,6 +70,7 @@ bool AppDelegate::applicationDidFinishLaunching() // pDirector->enableRetinaDisplay(true); // sets opengl landscape mode + // tests set device orientation in RootViewController.mm // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); // turn on display FPS diff --git a/tests/tests/controller.cpp b/tests/tests/controller.cpp index 5d59cc46a8..932adf5080 100644 --- a/tests/tests/controller.cpp +++ b/tests/tests/controller.cpp @@ -5,8 +5,21 @@ static CCPoint s_tCurPos = CCPointZero; +static ccDeviceOrientation s_eOrientation = CCDeviceOrientationPortrait; +static void ChangeOrientation(ccDeviceOrientation eOrientation) +{ + if (s_eOrientation != eOrientation) + { + s_eOrientation = eOrientation; + CCDirector::sharedDirector()->setDeviceOrientation(eOrientation); + } +} + static TestScene* CreateTestScene(int nIdx) { + // change to default orientation + ChangeOrientation(CCDeviceOrientationPortrait); + TestScene* pScene = NULL; switch (nIdx) @@ -34,7 +47,7 @@ static TestScene* CreateTestScene(int nIdx) case TEST_COCOSNODE: pScene = new CocosNodeTestScene(); break; case TEST_TOUCHES: - CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationLandscapeLeft); + ChangeOrientation(CCDeviceOrientationLandscapeLeft); pScene = new PongScene(); break; case TEST_MENU: pScene = new MenuTestScene(); break; @@ -52,12 +65,12 @@ static TestScene* CreateTestScene(int nIdx) pScene = new IntervalTestScene(); break; case TEST_CHIPMUNK: #if (CC_TARGET_PLATFORM != CC_PLATFORM_AIRPLAY) - CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationLandscapeLeft); + ChangeOrientation(CCDeviceOrientationLandscapeLeft); pScene = new ChipmunkTestScene(); break; #else #ifdef AIRPLAYUSECHIPMUNK #if (AIRPLAYUSECHIPMUNK == 1) - CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationLandscapeLeft); + ChangeOrientation(CCDeviceOrientationLandscapeLeft); pScene = new ChipmunkTestScene(); break; #endif #endif @@ -106,8 +119,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); diff --git a/tests/tests/controller.h b/tests/tests/controller.h index c0f7e4fe18..9e300683cb 100644 --- a/tests/tests/controller.h +++ b/tests/tests/controller.h @@ -19,7 +19,6 @@ public: virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent); private: - CCPoint m_tBeginPos; CCMenuItemLabel * m_pMenuItems[TESTS_COUNT]; CCMenu* m_pItmeMenu;