Friday 15 August 2014

ios - Detecting a double tap gesture only once -



ios - Detecting a double tap gesture only once -

- (void)touchesbegan:(nsset *)touches withevent:(uievent *)event { (uitouch *atouch in touches) { if (atouch.tapcount >= 2) { // view responds tap } } }

i'm using code above observe double tap gesture; however, how can set code happen once?

in other words, when tap once, character jumps. when tap twice in quick succession, character double jump. how set taps in way character not continuously double jump , go higher off single-view without taping once?

a simple approach of achieving declaring global bool variable , set value 1 time double tap has been detected!

something this:

@interface myviewcontroller() { bool istapped; } @end @implementation myviewcontroller - (void)touchesbegan:(nsset *)touches withevent:(uievent *)event { (uitouch *atouch in touches) { if (atouch.tapcount >= 2) { if(!istapped) { // view responds tap istapped = yes; } } } } @end

hope helps

ios objective-c sprite-kit xcode6

No comments:

Post a Comment