I have a touch function which changes the sprite animation and has the character jump into the air, but I need to be able have him run and jump and attack using touch. If I create multi functions, it overrides the previous one. How can I create a function which allows me to change the action to pick which one and change his action?
below is the code for only the jump change animation
local function onTouch(event) – creates the even function
if(event.phase == “began”)then – if this then that
animate:setSequence(“jumping”) – when touched sets the animation to jumping animation
animate:setLinearVelocity(0,-200) – jump 200 upward
animate:play() --run the animation
elseif(event.phase == “ended”)then – when the touch end
animate:setSequence(“idle”) --return the character to his idle stance
animate:play()-- run idle stance
end
end