我想在精灵套件中有一个摇动手势,我只能在视图控制器.m中执行这些功能,那么我如何获得摇动手势以便它在精灵套件中的不同场景上工作?因为当我在sprite中调用场景中的函数时函数没有被调用,所以如何在sprite kit场景中调用函数或者将它从视图控制器传递到Sprite Kit场景。感谢
答案 0 :(得分:0)
如何简单地将任何动作手势交给SKScene,如下所示: -
// hand-over motion gestures to SKScene
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
SKView * skView = (SKView *)self.view;
[skView.scene motionBegan:motion withEvent:event];
}
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
SKView * skView = (SKView *)self.view;
[skView.scene motionCancelled:motion withEvent:event];
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
SKView * skView = (SKView *)self.view;
[skView.scene motionEnded:motion withEvent:event];
}