I have a jump button that on touch will make my character jump. I want to allow only a single jump at a time, I am not sure how to achieve this. I tried checking getLinearVelocity() and see if it is set to 0 but no luck so far.
Here is my code, please help.
local canJump; local function isJumping(self, event) canJump = sprite:getLinearVelocity() end --Runtime Even local function isJump( event ) if(canJump == 0 ) then print( sprite:getLinearVelocity( ) ) sprite:setLinearVelocity( 0, -200 ) sprite:pause() sprite:setSequence("jump") sprite:play( ) else sprite:setLinearVelocity( 0, 0 ) sprite:pause() sprite:setSequence("rest") sprite:play( ) end end -- Touch even