2014-09-24 50 views
1

我的cocos2d应用程序具有抖动功能,我使用UIAccelerometer开发抖动功能。在iOS 8 UIA加速度计不工作。任何人都可以帮助我,如何检测cocos2d应用程序中的摇动手势。如何在iPhone Cocos2D中检测摇动手势?在iOS 8

感谢....

+0

' - (空)加速度计:(UIAccelerometer *)加速度计didAccelerate:(UIAcceleration *)acceleration' 是这个函数不工作..即使你使用..'[[UIAccelerometer sharedAccelerometer] setDelegate:self];'..或'self.isAccelerometerEnabled = YES;'在'init'或'CCLayer'中的'onEnter'? – 2014-10-08 11:28:01

+0

让我知道如果下来的答案不是你在找什么。将很乐意改变或删除。 - – 2014-10-09 23:56:42

回答

0

添加到您的视图控制器:

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