Chipmunk/cocos2D 中的横向模式
我正在尝试创建一个带有弹跳球的花栗鼠空间。(示例见此处)
目前我的设备正在横向模式下运行。所以根据cocos2D一切都好。添加精灵时,它们会定向为横向模式。
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
唯一的问题是,现在使用花栗鼠时,设备方向被搞乱了。当将 ipad 向左上角倾斜时,我的“弹跳球”会向右上角移动。
有没有办法手动旋转花栗鼠空间?
或者还有其他方法可以在花栗鼠空间内设置旋转吗?
I'm trying to create a chipmunk space with a bouncing ball.(Example seen here)
Currently my device is running in Landscape mode. So according to cocos2D everything is all right. When adding Sprites they orient to landscape mode.
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
The only problem is that the device orientation is screwed up when using chipmunk right now. When tilting the ipad towards the upper-left corner, my 'bouncing ball' moves towards the upper-right corner.
Is there a way to rotate a chipmunk space manually?
Or is there some other way to set rotation within a chipmunk space?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这听起来像是一个简单的标志问题。我假设球是通过向它们施加力来移动的。因此,当沿一个方向移动球时,不要应用像 (10, 0) 这样的正力,而是应用负力 (-10, 0),并在另一个方向上执行相反的操作(例如,将 x 坐标力乘以 -1)。 Chipmunk 不关心也不知道设备方向,它只是根据力和重力移动物体。
It sounds like a simple sign issue. I assume the balls are moved by applying a force to them. So instead of applying a positive force like (10, 0) apply a negative force (-10, 0) when moving the balls in one direction, and do the reverse in the other (eg multiply x coordinate forces by -1). Chipmunk doesn't care or know about device orientation, it just moves objects according to forces and gravity.