0
我試圖做一個遊戲,涉及點擊和拖動瓷磚創建路徑,類似於流行的遊戲Flow Free.選擇和拖動瓷磚
我希望能夠選擇瓷磚和滑動我的手指都在一個滑動,但我有一些問題。 我一直在使用SwipeGestures嘗試,在
// listen for swipes to the left
UISwipeGestureRecognizer * swipeLeft= [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeLeft)];
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
[[[CCDirector sharedDirector] view] addGestureRecognizer:swipeLeft];
// listen for swipes to the right
UISwipeGestureRecognizer * swipeRight= [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeRight)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
[[[CCDirector sharedDirector] view] addGestureRecognizer:swipeRight];
// listen for swipes up
UISwipeGestureRecognizer * swipeUp= [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeUp)];
swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
[[[CCDirector sharedDirector] view] addGestureRecognizer:swipeUp];
// listen for swipes down
UISwipeGestureRecognizer * swipeDown= [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeDown)];
swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
[[[CCDirector sharedDirector] view] addGestureRecognizer:swipeDown];
我的問題是SwipeGestures只承認每個屏幕上,按下一個刷卡 - 如果我改變方向,中期刷卡,不登記。
假設我需要使用UIGestureRecognizers,是否可以使用PanGestureRecognizer和SwipeGestureRecognizer來持續檢查滑動方向的變化? 任何幫助,將不勝感激。提前致謝!
這是因爲您正在爲每個滑動方向傳遞不同的方法,而不是讓UIPanGestureRecognizer檢測滑動方向。 –