【问题标题】:How can I change the view from portrait to landscape mode?如何将视图从纵向模式更改为横向模式?
【发布时间】:2011-02-14 15:53:33
【问题描述】:

我想将第一个视图更改为纵向模式,第二个视图进入横向模式,我正在使用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,但是没找到解决办法。

【问题讨论】:

  • 请格式化您的代码。像这样读起来真的很难……

标签: iphone cocos2d-iphone


【解决方案1】:

当你想改变方向时,调用这个函数:

[[CCDirector sharedDirector]setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];

【讨论】:

    【解决方案2】:

    我很容易在#define kGameAutorotationUIViewController 2 view 的帮助下解决我的问题,每当我将其值更改为 1 时,方向为纵向模式,当我更改其值时,视图将以横向模式显示,谢谢给我建议

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-26
      • 1970-01-01
      • 2014-05-11
      • 1970-01-01
      • 2017-11-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多