I have a problem when moving my character with a button, but it will apply to every button I have with a event phase cancelled or ended I’ll have, so I better ask this now. I don’t really know how the cancelled works, but it’s not working for me, if I touch the button and drag the mouse outside of the button and unclick while outside, for some reason the event didn’t get the event.ended or cancelled and so the character’s movement didn’t stop.
This is what I have:
function moveRight:touch(event)
moveX = speed;
if event.phase ==“ended” or event.phase==“cancelled” then
moveX = 0;
end
return true
end
moveRight:addEventListener(“touch”,moveRight)
local function moveCharacter (event)
character.x = character.x + moveX;
end
Runtime:addEventListener(“enterFrame”, moveCharacter )
The character keeps moving when I drag the mouse and unclick outside of the button, I want it to not count it as clicked anymore and have the moveX reset to 0. What can I do?
Also, is this the best way to manage the character movement?
[import]uid: 53195 topic_id: 33330 reply_id: 333330[/import]