2011-02-14 132 views
0

我想在縱向模式下更改第一個視圖,並且第二個視圖進入橫向模式,我正在使用gameconfig.h文件。如何將縱向視圖更改爲橫向模式?

的代碼是:

// 
// GameConfig.h 
// Cocos2DSimpleGame 
// 
// Created by Ray Wenderlich on 11/21/10. 
// Copyright Ray Wenderlich 2010. All rights reserved. 
// 

#ifndef __GAME_CONFIG_H 
#define __GAME_CONFIG_H 

// 
// Supported Autorotations: 
//  None, 
//  UIViewController, 
//  CCDirector 
// 
#define kGameAutorotationNone 0 
#define kGameAutorotationCCDirector 1 
#define kGameAutorotationUIViewController 2 //2 
// 
// Define here the type of autorotation that you want for your game 
// 
#define GAME_AUTOROTATION kGameAutorotationUIViewController 


#endif // __GAME_CONFIG_H 


and in my appDelegate file is: 
#if GAME_AUTOROTATION == kGameAutorotationUIViewController 
    [director setDeviceOrientation:kCCDeviceOrientationPortrait]; 
#else 
    [director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft]; 

    //[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft]; 
// [director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft]; 
#endif 

在我想縱向顯示模式菜單中的第一個視圖,並且還當我點擊新遊戲,則遊戲會在橫向模式下顯示。我也使用shouldAutoInterfaceOrientation,但我還沒有找到解決方案。

+0

請格式化您的代碼。像這樣閱讀真的很難...... – 2011-02-14 16:21:03

回答

0

每當我它的值改爲1取向我很容易地解決我的問題的#define kGameAutorotationUIViewController 2視圖的幫助是肖像模式和時我改變了它的價值觀點將顯示在橫向模式,thnx給我的建議

1

當你想改變方向,調用這個函數:

[[CCDirector sharedDirector]setDeviceOrientation:kCCDeviceOrientationLandscapeLeft]; 
相關問題