设置正确的 cocos2d 方向 [英] setting proper cocos2d orientation
问题描述
在我的 cocos2d 应用程序中,在我的应用程序委托的 applicationDidFinishLaunching 方法中,我通过 [director setDeviceOrientation:kCCDeviceOrientationPortrait] 设置方向,因为我真的只想要纵向.但是,Apple 拒绝了我的应用,说它也必须支持倒置肖像.
In my cocos2d application, inside the applicationDidFinishLaunching method for my app delegate, I set the orientation via [director setDeviceOrientation:kCCDeviceOrientationPortrait] because I really only want portrait. However, Apple rejected my app saying it must support upside down portrait as well.
不过,我不确定我是如何检测到这一点的.读取 currentDevice 方向似乎返回了一个未知的方向,所以我的问题是双重的:
I'm not certain how I detect this, though. Reading the currentDevice orientation seems to return an unknown orientation, so my questions are twofold:
1) 我应该如何检测方向,以便我可以正确地将其设置为纵向或倒置纵向(它将永远保持不变).
1) How am I supposed to detect the orientation so I can properly set it to either portrait or upsidedown portrait (where it will stay for good).
2) 我怀疑启动画面会出现问题,因为它是在我到达委托中的这一点之前加载的.如何正确检测方向以便设置正确的初始屏幕?
2) I suspect I'll have an issue with the splash screen because it's loaded before I reach this point in the delegate. How can I properly detect the orientation so I can set the right splash screen?
推荐答案
我只能编辑代码来解决你的第一个问题..我希望你使用.99.5..
I can only edit the codes to fix your first question.. i hope you are using .99.5..
在RootViewController.h中,在函数中
in RootViewController.h, in the function
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
寻找这一行:
#elif GAME_AUTOROTATION == kGameAutorotationUIViewController
{
return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );
}
改成
return ( UIInterfaceOrientationIsPortrait( interfaceOrientation ) );
这篇关于设置正确的 cocos2d 方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!