Hi,
I have right and left arrow in my game to control the main character, I realize that if i touch both at the same time OR touch left button before release the right arrow (while holding one arrow then press another arrow) the character will stop moving.
Below is the code that i used for the left touch event:
function touchleft (event) if event.phase == "began" then if gameIsActive == true then pencetKiri = true pencetKanan = false motionx = -speed motiony = 0 physics.removeBody( player ) local triangleShape = { -25,10, -25,-45, 18,10, 18,-45} physics.addBody(player, {shape=triangleShape,density = 0, friction = 0, bounce = 0}) player.bodyType = "kinematic" player:setSequence("playerleft") player:play("playerleft") end elseif event.phase == "moved" then -- do nothing else motionx = 0 motiony = 0 player:pause() end return true end left:addEventListener("touch", touchleft)
Right arrow event using the same code but different motionX.
What i want to achieve is the character should move to the last arrow he touched.
Let say when i touch the left arrow and after that i touch the right arrow without releasing the left arrow, the character should move to the right.
Please advise.
Thank You