我有关于使用滑动手势的问题。
问题是我想要在左右点击改变方向的同时左右滑动。
我可以在这种情况下使用CCTouch方法吗?如果是,那我该怎么用?还有另一种方法吗?
答案 0 :(得分:0)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
...
[self createSwipeRecognizerView];
return YES;
}
-(void) createSwipeRecognizerView {
//NSLog(@"Creating Swipe Recognizer");
UIGestureRecognizer *recognizer;
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(screenDidswipe)];
// swipeRightOnTable is the callback method in my case
swipeRecognizer = (UISwipeGestureRecognizer *)recognizer;
// select swipe direction
swipeRecognizer.direction = UISwipeGestureRecognizerDirectionUp;
[self.navController.view addGestureRecognizer:recognizer];
recognizer.delegate = self;
[recognizer release];
}
-(BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if([[MyGame sharedGameObject].layer isKindOfClass:[MyGameScreen class]])
return YES;
return NO;
}
-(void) screenDidswipe
{
MyGame *sGame = [MyGame sharedGameObject];
if([sGame.layer isKindOfClass:[MyGameScreen class]])
{
[(MyGameScreen*)(sGame.layer) screenDidswipe];
}
}