Swift:有选择地防止SpriteKit场景的自动屏幕旋转
我有一个iOS应用程序,该应用程序将有许多SpriteKit场景。这些场景应保持肖像和景观的屏幕上的相同方向。例如,一个场景将在屏幕上有一条双车道路,即 ie。它将在肖像中向上/向下奔跑,并在景观中向左/右行。 。我不希望它可以自动与设备自动旋转,尽管我会在屏幕上旋转文本以使其可读(我可以这样做)。
还有许多其他视图(主要是文本)仍应自动旋转,因此我不想在“部署信息”中取消选择选项。
有什么想法如何选择/防止设备自动旋转?我希望计算车辆位置之间的方向不变。理想情况下,只需旋转场景即可。
I have an iOS application that will have a number of SpriteKit scenes. These scenes should remain in the same orientation on the screen in both portrait and landscape. For example one scene will have a dual carriageway road running lengthways on the screen ie.it will run up/down in portrait and left/right in landscape. I don't want it to auto rotate with the device, although I will be rotating text on the screen to keep it readable (I can do this).
There are a number of other views (mainly text) that should still auto rotate so I don't want to deselect options in 'Deployment Info'.
Any ideas how to selectively allow/prevent auto rotation with the device? I want calculations for the vehicle positions to be unchanged between orientations. Ideally just rotate the scene.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一种允许设备在最高级别旋转的方法,同时模拟在Skscene级别没有旋转的方法。您可以在SwiftUI中接收设备旋转事件,然后将该信息传递到您的场景中,
相应的Skscene只需要具有一个包含所有图形元素的顶级Sknode。您在该容器上相应地旋转
here is a way to allow device rotation at top level, while simulating no rotation at SKScene level. you can receive device rotation events in SwiftUI and then pass that information down to your scene
the corresponding SKScene simply needs to have a top level SKNode that contains all graphical elements as children. you set rotation accordingly on that container