相关疑难解决方法(0)

SpriteKit手势识别器

嗨,我正在尝试使用手势识别器与我的精灵套件游戏,我写了这段代码

@interface GameScene() <UIGestureRecognizerDelegate>{

  UISwipeGestureRecognizer *swipeGestureLeft;
  ISwipeGestureRecognizer *swipeGestureRight;
}
@end

@implementation GameScene
-(id)initWithSize:(CGSize)size{

    if(self = [ super initWithSize:size]){

    }

    return  self;
}

-(void)didMoveToView:(SKView *)view{

    swipeGestureLeft = [[UIGestureRecognizer alloc]initWithTarget:self action:@selector(swipeLeft)];
    [swipeGestureLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
    [view addGestureRecognizer:swipeGestureLeft];

    swipeGestureRight = [[UIGestureRecognizer alloc]initWithTarget:self action:@selector(swipeRight)];
    [swipeGestureRight setDirection:UISwipeGestureRecognizerDirectionRight];
    [view addGestureRecognizer:swipeGestureRight];
}

- ( void ) willMoveFromView: (SKView *) view {

    [view removeGestureRecognizer: swipeGestureLeft ];
    [view removeGestureRecognizer: swipeGestureRight];
}

-(void)swipeLeft:(UISwipeGestureRecognizer*) recognizer{

    NSLog@"Left"'
}

-(void)swipeRight:(UISwipeGestureRecognizer*) recognizer{

    NSLog@"Right"'
}


@end
Run Code Online (Sandbox Code Playgroud)

我认为每件事都没问题,但我的手势不起作用,我没有错误信息,是否有什么遗漏我应该添加到我的应用程序,或者我应该添加一些东西给我的视图控制器,或者你们可以建议我一个totorial向我展示了如何使用sprite kit手势,

objective-c uigesturerecognizer sprite-kit xcode6

4
推荐指数
1
解决办法
547
查看次数