我是cocos2d API的新手,并且注意到有几种方法可以在模板中设置屏幕方向。我一直无法找出将我的方向设置为LandscapeRight并在整个游戏中保持这种方式的正确方法。如何更改方向以保持LandscapeRight?任何帮助表示赞赏。谢谢!Cocos2d - 设置设备/屏幕方向
1
A
回答
5
修改GameConfig.h从cocos2d的模板。
#define GAME_AUTOROTATION kGameAutorotationNone
/* original code is kGameAutorotationUIViewController. */
并修改AppDelegate.m。
#if GAME_AUTOROTATION == kGameAutorotationUIViewController
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
#else
[director setDeviceOrientation:kCCDeviceOrientationLandscapeRight];
/* original code is "Left". */
#endif
3
使用此行:
[[CCDirector sharedDirector] setDeviceOrientation:kkCCDeviceOrientationLandscapeRight];
1
在RootViewController.m,搜索线
return (UIInterfaceOrientationIsPortrait(interfaceOrientation));
改变它
return (UIInterfaceOrientationIsLandscape(interfaceOrientation));
8
这里的答案与cocos2d的2.0改变,因为现在CCDirector是一个视图控制器iOS:
CCDirector不再支持devic e方向。所有自动旋转和 设备方向现在由RootViewController处理。幸运的是, [[UIDevice currentDevice]方向]可用于代替 [[CCDirector sharedDirector] deviceOrientation]。枚举是 相同,除了它们以UI而不是CC开头。
强制特定取向是返回YES 仅在RootViewController的方法 shouldAutorotateToInterfaceOrientation所需取向的一个简单的事情。
Choosing between Cocos2D v1.x & 2.x and Tips for updating to Cocos2D 2.0 at learn-cocos2d.com
-2
正确的答案 - 我花了一段时间来找到 - 在info.plist中,改变支持的接口方位值,项0和1项有4个可能的值,人像(顶级家居按钮)等
0
如果添加shouldAutorotateToInterfaceOrientation并没有解决你的问题
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
THEN 尝试添加该林E要appDelegate.m
[window_ setRootViewController:navController_];
好运
相关问题
- 1. 如何设置默认屏幕方向?
- 2. 通过设备设置Android应用屏幕方向
- 3. cocos2d-js android设备方向
- 4. 屏幕尺寸和设备方向
- 5. cocos2d屏幕方向问题
- 6. 在cocos2d iPhone反向设备方向
- 7. 设置屏幕方向变得可见
- 8. 确定屏幕的方向而不是设备的方向
- 9. Android设备/屏幕支持
- 10. Android设备屏幕截图
- 11. 为小屏幕设备
- 12. cocos2d场景只能占用设备屏幕的一部分吗?
- 13. 设置正确的cocos2d方向
- 14. 屏幕方向对于平板电脑和设备
- 15. 如何全局锁定Android设备屏幕方向
- 16. 如何修复Android上不同设备的屏幕方向
- 17. 如何确定C#中移动设备屏幕的方向?
- 18. 设备被阻止时的Android屏幕方向
- 19. 如何在横向视图中设置屏幕方向,如iphone
- 20. iOS 8屏幕边界设备和横向模拟器的不同设置
- 21. 设备方向设置不影响iPad设备
- 22. 根据设备类型设置设备方向
- 23. Android:禁用插入时保持设备屏幕的设置
- 24. 设置通用设备(iPhone和iPad)的屏幕
- 25. 设置相应的设备屏幕尺寸的Textview尺寸
- 26. 如何检测/识别设备锁定屏幕设置是否设置为无?
- 27. 将方向设置为大屏幕风景
- 28. 我如何设置“div”大小根据手机屏幕方向
- 29. 如何为其他应用程序设置屏幕方向?
- 30. 如何根据当前屏幕方向设置活动内容?
你的答案真的不是很清楚。 – 2013-01-02 05:38:36