如何使用cocos2d为iphone做手势识别器?

时间:2011-04-21 16:07:43

标签: iphone cocos2d-iphone

如何使用cocos2d为iphone做手势识别器? 只有左/右/上/下 任何人都可以给我一些例子或教程吗? 非常感谢。

1 个答案:

答案 0 :(得分:0)

代码下方的{p> guestures是swipeguesture的一些示例,您可以从上面的链接获取孔文档。在didswipe方法中是用户方法

`UISwipeGestureRecognizer *swipeGestureRecognizerright = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipe:)];
    swipeGestureRecognizerright.direction = UISwipeGestureRecognizerDirectionRight;
    swipeGestureRecognizerright.numberOfTouchesRequired = 1;
    swipeGestureRecognizerright.delegate = self;

    [self.scrollView addGestureRecognizer:swipeGestureRecognizerright];
    [swipeGestureRecognizerright release];

-(void)didswipe:(UISwipeGestureRecognizer *)gesture{
//do something


}
`