cocos2d屏幕方向问题
我使用 cocos2d 0.99-rc0 中存在的标准旋转代码来支持纵向 + 两种横向模式。我以纵向模式显示菜单,然后屏幕旋转到横向以进行实际游戏。问题是,当我返回纵向时,整个主菜单场景偏离了屏幕的一半,就像有人移动了锚点或其他东西一样。
有什么想法吗?
I am using the standard rotation code present in cocos2d 0.99-rc0 to support portrait + two landscape modes. I am showing the menu in portrait mode, and then the screen rotates to landscape for the actual game. Problem is that when i go back to portrait, the whole mainmenu scene is off by half the screen, like someone had moved the anchor point or something.
Any ideas please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个可能的简单解决方案是在场景开始时应用方向,然后重新应用菜单项的位置,使其全部对齐。
我执行以下操作来更改屏幕方向:
首先,第一行进入 init 方法内部,我设置一个计时器在 0.5 秒后快速启动。将其放入计时器意味着在我的游戏中,场景转换(淡入淡出)可以顺利进行,屏幕不会旋转/快速旋转,但您可能不需要使用它。
关键行如下,您不一定需要计时器:
当然您可以针对不同的方向更改此位:
祝您好运。
A possible simple solution would be to apply the orientation at the start of the scene then after wards re-apply the positions of your menu items so that its all aligned.
I do the following to change the screen orientation:
Firstly, the first line goes inside the init method I set a timer to start after a quick 0.5 seconds. Putting it in a timer means in my game the scene transition (fade) works smoothly, the screen doesn't rotate/snap round then, but you probably won't need to use this.
The key line is below, you don't necessarily need the timer:
Of course you can alter this bit for different orientations:
Good luck.