tôi đang cố gắng để có được những swiping để làm việc cho Cocos2d phiên bản mới nhất tại đây là mã của tôi:Vuốt trong Coco2d
-(void) setupGestureRecognizers
{
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeft)];
[swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[swipeLeft setNumberOfTouchesRequired:1];
[[[CCDirector sharedDirector] openGLView] addGestureRecognizer:swipeLeft];
}
Nó không phát hiện các swipe ở tất cả!
CẬP NHẬT 1:
Tôi đã cập nhật mã thành mã sau đây và vẫn không phát hiện thấy swipes.
-(void) setupGestureRecognizers
{
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeft)];
[swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[swipeLeft setNumberOfTouchesRequired:1];
[[[[CCDirector sharedDirector] openGLView] window] setUserInteractionEnabled:YES];
[[[CCDirector sharedDirector] openGLView] setUserInteractionEnabled:YES];
[[[CCDirector sharedDirector] openGLView] addGestureRecognizer:swipeLeft];
}
Tôi thích sử dụng UIGestureRecognizer vì dễ dàng tạo các loại sự kiện cảm ứng khác nhau. – azamsharp
đây là thiên tài! –