iphone - ccTouchBegan Function Is Executing If-Statement Incorrectly -


i'm attempting read , store touches on ios device using cocos2d. method handle each touch (multitouch enabled) individually in cctouchbegan, cctouchmoved, cctouchcanceled, , cctouchended functions.

the ivars of importance are:

  • activetouches (int incremented or decremented when new valid touch (valid meaning not near joystick) received).
  • acceptinggestures (bool used ignore new touches)
  • gesturetimer (float continuously incremented cctime in update function. when above threshold, acceptinggestures set false)

here code:

-(bool) cctouchbegan:(uitouch *)touch withevent:(uievent *)event {     cgpoint touchlocation = [touch locationinview: [touch view]];     touchlocation = [[ccdirector shareddirector] converttogl: touchlocation];     touchlocation = [self converttonodespace:touchlocation];      //check see if touch near joystick prevent accidental gestures. may want consider increasing 'deadzone' value     if(abs(self.joysticklocation.x - touchlocation.x) <= 35 && abs(self.joysticklocation.y - touchlocation.y) <= 35)     {         return no;     }      if(self.activetouches == 0)     {         [self setgesturetimerenable:true];         [self setgesturetimer:0.0f];     }      if(self.acceptinggestures == true);     {         if (self.firsttouch == nil)         {             self.firsttouch = touch;             self.activetouches++;             return yes;         }         else if (self.secondtouch == nil)         {             self.secondtouch = touch;             self.activetouches++;             return yes;         }     }      cclog(@"touched: %f, %f\n",touchlocation.x, touchlocation.y);     return no; } 

i'm experiencing weird problem in cctouchbegan function. test scenario, using emulator, have 1 touch recognized software , gesturetimer running. after x time, gesturetimer surpasses threshold , sets acceptinggestures false. apply 2nd touch screen, , code accepts touch , increments activetouches variable! shouldn't able that!

i set breakpoint using debugger , tried capture weird event. though acceptinggestures false (the acceptinggestures expression @ breakpoint indeed false), code still makes through if-statement! in screenshot attached, notice acceptinggestures false.

i appreciate help! thank you!

debugger screenshot. notice acceptinggestures false.

i found problem. had semicolon after if-statement! womp womp. wanted delete post maybe see gesture code , gain it?


Comments

Popular posts from this blog

asp.net mvc 3 - Using mvc3, I need to add a username/password to the sql connection string at runtime -

kineticjs - draw multiple lines and delete individual line -

thumbnails - jQuery image rotate on hover -