Hi,
I have 2 image “right arrow” and “left arrow”. I add 1 touch event for each of the image. The purpose of that touch event is to move the sprite right or left.
Below is the code for left arrow(for right arrow’s touch event i use about the same code just change “left” to “right”)
function touchleft (event)
if event.phase == "began" then
if gameIsActive == true then
pencetKiri = true
pencetKanan = false
motionx = -speed
motiony = 0
player:prepare("playerleft")
player:play("playerleft")
display.getCurrentStage():setFocus(event.target,event.id)
end
elseif event.phase == "ended" or event.phase == "cancelled" then
display.getCurrentStage():setFocus(event.target,nil)
end
end
left:addEventListener("touch", touchleft)
I found some weird behavior if i do these steps in my arrow:
- press left/right arrow
- with another thumb pres anywhere on the screen
- release the thumb that press left/right arrow
the weird behavior in my case is the sprite keep moving to right/left (by right should stop when the thumb no longer press the arrow).
Any idea what is the root cause and solution for this problem?
Thank You.
[import]uid: 114765 topic_id: 27062 reply_id: 327062[/import]