Modify tests doesn't change orientation every test scene.

This commit is contained in:
yangws 2011-05-03 11:37:30 +08:00
parent 2b94d7d9ce
commit e723a424d8
3 changed files with 17 additions and 6 deletions

View File

@ -70,6 +70,7 @@ bool AppDelegate::applicationDidFinishLaunching()
// pDirector->enableRetinaDisplay(true); // pDirector->enableRetinaDisplay(true);
// sets opengl landscape mode // sets opengl landscape mode
// tests set device orientation in RootViewController.mm
// pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
// turn on display FPS // turn on display FPS

View File

@ -5,8 +5,21 @@
static CCPoint s_tCurPos = CCPointZero; 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) static TestScene* CreateTestScene(int nIdx)
{ {
// change to default orientation
ChangeOrientation(CCDeviceOrientationPortrait);
TestScene* pScene = NULL; TestScene* pScene = NULL;
switch (nIdx) switch (nIdx)
@ -34,7 +47,7 @@ static TestScene* CreateTestScene(int nIdx)
case TEST_COCOSNODE: case TEST_COCOSNODE:
pScene = new CocosNodeTestScene(); break; pScene = new CocosNodeTestScene(); break;
case TEST_TOUCHES: case TEST_TOUCHES:
CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationLandscapeLeft); ChangeOrientation(CCDeviceOrientationLandscapeLeft);
pScene = new PongScene(); break; pScene = new PongScene(); break;
case TEST_MENU: case TEST_MENU:
pScene = new MenuTestScene(); break; pScene = new MenuTestScene(); break;
@ -52,12 +65,12 @@ static TestScene* CreateTestScene(int nIdx)
pScene = new IntervalTestScene(); break; pScene = new IntervalTestScene(); break;
case TEST_CHIPMUNK: case TEST_CHIPMUNK:
#if (CC_TARGET_PLATFORM != CC_PLATFORM_AIRPLAY) #if (CC_TARGET_PLATFORM != CC_PLATFORM_AIRPLAY)
CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationLandscapeLeft); ChangeOrientation(CCDeviceOrientationLandscapeLeft);
pScene = new ChipmunkTestScene(); break; pScene = new ChipmunkTestScene(); break;
#else #else
#ifdef AIRPLAYUSECHIPMUNK #ifdef AIRPLAYUSECHIPMUNK
#if (AIRPLAYUSECHIPMUNK == 1) #if (AIRPLAYUSECHIPMUNK == 1)
CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationLandscapeLeft); ChangeOrientation(CCDeviceOrientationLandscapeLeft);
pScene = new ChipmunkTestScene(); break; pScene = new ChipmunkTestScene(); break;
#endif #endif
#endif #endif
@ -106,8 +119,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);

View File

@ -19,7 +19,6 @@ public:
virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent); virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent);
private: private:
CCPoint m_tBeginPos; CCPoint m_tBeginPos;
CCMenuItemLabel * m_pMenuItems[TESTS_COUNT]; CCMenuItemLabel * m_pMenuItems[TESTS_COUNT];
CCMenu* m_pItmeMenu; CCMenu* m_pItmeMenu;