I have a problem with detecting a shake. It's a skscene in the Sprit Kit and I defined the motion detector like this:
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{
}
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
NSLog(@"test?");
}
Where is my mistake? Do I have to implement it like I had to do it with the UIGestureRecognizer?
Thanks in advance (and sorry for my bad english) Julian
Apparently, you can't detect shake events from a
SKScene
subclass, such asGameScene
. However, you can detect them from a view controller, such asGameViewController
. When a shake event is triggered, you can call a shake handler inGameScene
from the view controller.In your GameViewController.m, add this to detect shake events
Add this to the @interface in GameScene.h
Add this to GameScene.m