[ios.cocos2d + box2d]如何禁用自动旋转?

编程入门 行业动态 更新时间:2024-10-26 16:27:43
本文介绍了[ios.cocos2d + box2d]如何禁用自动旋转?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用cocos2d 0.99.5 + box2d创建了一个项目。 当我旋转我的iphone,屏幕自动旋转了。

I have created a project with cocos2d 0.99.5 + box2d. When I rotate my iphone, Screen automatically rotated too. So the boxes Flew up into the ceiling.

如何禁用自动旋转?

plz

推荐答案

在coco2d 0.99.5中,模板创建一个名为GameConfig.h的文件,应用程序的旋转。默认为

In coco2d 0.99.5, the template creates a file called GameConfig.h, where you get to choose what system controls the app's rotation. The default is

#define GAME_AUTOROTATION kGameAutorotationUIViewController

现在看看RootViewController.m,或者你在文件中命名的任何内容。在

Now take a look inside RootViewController.m, or whatever you've named it in your file. in the

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

方法,您会看到一些 #if 和 #elif 编译指令。查看kGameAutorotationUIViewController发送给我们的部分:

method, you'll see a number of #if and #elif compiler directives. Check out the section that kGameAutorotationUIViewController sends us to:

#elif GAME_AUTOROTATION == kGameAutorotationUIViewController // // EAGLView will be rotated by the UIViewController // // Sample: Autorotate only in landscpe mode // // return YES for the supported orientations if( interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight ) return YES; // Unsupported orientations: // UIInterfaceOrientationPortrait, UIInterfaceOrientationPortraitUpsideDown return NO;

要使游戏保持单向,请将中间if语句更改为:

To keep your game at a single orientation, change that middle if statement to read:

if( interfaceOrientation == UIInterfaceOrientationPortrait) return YES;

或者你决定的方向是你想要的。希望这有助于!

Or whatever orientation you decide it is that you want. Hope this helps!

更多推荐

[ios.cocos2d + box2d]如何禁用自动旋转?

本文发布于:2023-06-05 01:12:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/508800.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ios   cocos2d   box2d

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!