2010-05-30 141 views
0

我正在使用UIKit制作一个简单的,倾斜控制的游戏。到目前为止,当我倾斜设备时,角色会朝适当的方向移动。我想要他做的是改变我倾斜设备时面临的方向。例如,当我向左倾斜时,我希望角色朝左。有没有办法检测设备是左倾还是右倾?如果是这样,请你指点我正确的方向。 谢谢, 泰特iPhone倾斜方向

+2

您是否已经有足够的信息来做出决定?如果你知道什么方向移动,你也知道要面对什么方向。 – 2010-05-30 18:30:22

回答

0

如果知道实际的旋转是否足够你。然后,我会建议使用的UIViewController并覆盖- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation方法

如果你需要更多的东西,那么我会建议做一个有关加速度计

+0

加速计教程: http://www.switchonthecode.com/tutorials/iphone-tutorial-reading-the-accelerometer UIViewController参考: http://developer.apple.com/iphone/library/documentation/uikit/reference /UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/didRotateFromInterfaceOrientation: – nacho4d 2010-05-30 18:35:24

+0

我需要更多的基于倾斜的控件而不是完整的方向更改,但感谢您的尝试。 -Tate – 2010-05-30 20:54:58