Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Im using UIPanGestureRecognizer in my cocos2d game to do drag and drop of sprites. I have a row of sprites and when I drag a sprite on top of another one, the sprite underneath it and any other sprites between should shift left or right out of the way to allow space to drop the currently selected sprite.

This is working ok, however, if I am too quick at dragging the sprite around the screen, this triggers another round of the UIPanGestureRecognizer's callback method, and screws up the logic, as the sprites are in-between shifting.

I need a way to freeze the callback from firing, whilst the other sprites are shifting, then once they have finished moving, re-enable the callback to fire.

Whats the best way to do this?

share|improve this question
add comment

1 Answer

You can set the enabled property to NO, which will disable that gesture recognizer, until you re-enable it. If for some reason the recognizer is disabled while in the process of firing, it'll transition to its canceled state prior to being disabled.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.