Cocos2d iphone Cocos2d游戏方向向左切换->;右->;发射后直接离开

Cocos2d iphone Cocos2d游戏方向向左切换->;右->;发射后直接离开,cocos2d-iphone,uiinterfaceorientation,Cocos2d Iphone,Uiinterfaceorientation,我使用的是默认的cocos2d模板,基本代码略有修改。
我的游戏只在左边或右边玩-没有肖像。 当游戏启动时,它会从右开始,然后上下翻转,然后再向右翻转。 我浏览了几篇关于这个问题的帖子,似乎无法确定是什么原因导致界面在不移动设备的情况下前后翻转。感谢您的帮助 我有以下相关代码: RootViewController.m: #if GAME_AUTOROTATION == kGameAutorotationUIViewController -(void)willRotateToInterface

我使用的是默认的cocos2d模板,基本代码略有修改。

我的游戏只在左边或右边玩-没有肖像。

当游戏启动时,它会从右开始,然后上下翻转,然后再向右翻转。
我浏览了几篇关于这个问题的帖子,似乎无法确定是什么原因导致界面在不移动设备的情况下前后翻转。
感谢您的帮助

我有以下相关代码:

RootViewController.m:

#if GAME_AUTOROTATION == kGameAutorotationUIViewController

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    CGRect rect = CGRectZero;

    if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)      
        rect = screenRect;

    else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
        rect.size = CGSizeMake( screenRect.size.height, screenRect.size.width );

    CCDirector *director = [CCDirector sharedDirector];
    EAGLView *glView = [director openGLView];
    float contentScaleFactor = [director contentScaleFactor];

    if( contentScaleFactor != 1 ) {
        rect.size.width *= contentScaleFactor;
        rect.size.height *= contentScaleFactor;
    }
    glView.frame = rect;
}
#endif
AppDelegate:

#if GAME_AUTOROTATION == kGameAutorotationUIViewController
    [director setDeviceOrientation:kCCDeviceOrientationPortrait];
#else
    [director setDeviceOrientation:kCCDeviceOrientationLandscapeRight];
#endif
GameConfig.h:

#define kGameAutorotationNone 0
#define kGameAutorotationCCDirector 1
#define kGameAutorotationUIViewController 2

#if defined(__ARM_NEON__) || TARGET_IPHONE_SIMULATOR
#define GAME_AUTOROTATION kGameAutorotationUIViewController

#elif __arm__
#define GAME_AUTOROTATION kGameAutorotationNone

今天我遇到了同样的问题,这似乎取决于我的应用程序plist中支持的方向的顺序。该应用程序将在横向左侧启动,向右翻转,然后再快速向左翻转

我在“摘要”选项卡中进入了我的项目属性(您可以在其中配置支持的方向、应用程序图标、启动图像等),并取消选择所有支持的方向

然后,我再次按顺序勾选它们(横向右,横向左)-并在“信息”选项卡中验证它们在数组中的顺序,在“支持的界面方向”部分下

项目0-横向(右主页按钮) 项目1-横向(左主按钮)


没有问题,希望这有帮助。

请重新发布没有HTML格式的代码,目前无法阅读。谢谢!你不知道我在这件蠢事上浪费了多少时间!