How to implement Kobold2D KKInput gestureSwipeDirection to if else statements? -


i'm finding hard learn documentation on how can use kobold2d kkinput gestureswipedirection detect swipes left/right/up/down , have them carry out if else statements. can providing me sample code. thanks

kkinput* input = [kkinput sharedinput]; kkswipegesturedirection dir = input.gestureswipedirection; switch (dir) {     case kkswipegesturedirectionright:         // direction-specific code here         break;     case kkswipegesturedirectionleft:         // direction-specific code here         break;     case kkswipegesturedirectionup:         // direction-specific code here         break;     case kkswipegesturedirectiondown:         // direction-specific code here         break; } 

i think you're making mistake, you're placing code in single method, should use 2 hands, 1 determine kkinput, , 1 check status, plus forgot gestureswipeenabled

try this:

-(id) init {      if ((self=[super init])) {          input = [kkinput sharedinput];         input.gestureswipeenabled = yes;          [self schedule:@selector(thetime:)];      }     return self; }  -(void) thetime:(cctime)time {      if (input.gestureswiperecognizedthisframe) {          kkswipegesturedirection dir = input.gestureswipedirection;         switch (dir)         {             case kkswipegesturedirectionright:                 // direction-specific code here                 break;             case kkswipegesturedirectionleft:                 // direction-specific code here                 break;             case kkswipegesturedirectionup:                 break;             case kkswipegesturedirectiondown:                 // direction-specific code here                 break;             default:                 break;         }     } } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -