【问题标题】:How to detect shake Gesture in your iPhone Cocos2D? in iOS 8如何检测 iPhone Cocos2D 中的抖动手势?在 iOS 8 中
【发布时间】:2014-09-24 16:42:11
【问题描述】:

我的 cocos2d 应用程序有摇动功能,我使用 UIAccelerometer 开发摇动功能。在 iOS 8 UIAccelerometer 仪表不工作。任何人都可以帮助我,如何检测 cocos2d 应用程序中的摇动手势。

谢谢....

【问题讨论】:

  • - (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration 这个功能不工作吗.. 即使你使用.. [[UIAccelerometer sharedAccelerometer] setDelegate:self]; .. 或init 中的self.isAccelerometerEnabled = YES;CCLayer 中的onEnter
  • 如果不符合您的要求,请告诉我。将很乐意更改或删除。 ——

标签: ios cocos2d-iphone uiaccelerometer


【解决方案1】:

将此添加到您的视图控制器:

override func motionEnded(motion: UIEventSubtype, withEvent event: UIEvent?) {
    if motion == .MotionShake {
        // do something cool
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多