i have my code below, which to detect left/right click and move the player respectively.
local function onArrowEvent(event)
local t = event.target
print('event.phase = ' .. event.phase)
if event.phase == 'began' then
if t.moveDir == 'left' then
moveX = moveX + (-3)
end
if t.moveDir == 'right' then
moveX = moveX + (3)
end
end
if event.phase == 'ended' then
if t.moveDir == 'left' then
moveX = moveX + (3)
end
if t.moveDir == 'right' then
moveX = moveX + (-3)
end
end
end
btnLeftArrow:addEventListener('touch', onArrowEvent)
btnRightArrow:addEventListener('touch', onArrowEvent)
it worked fine if i touch & release the left/right button (coz event ‘began’, ‘ended’ are triggered)
But if i touch & drag till i am far away from the left/right button, only ‘began’ and ‘moved’ events are triggered. in such case, the ‘ended’ event will not be detect.
How can we get rid of such situation?
Thanks for the pointer [import]uid: 10373 topic_id: 22438 reply_id: 322438[/import]
[import]uid: 52491 topic_id: 22438 reply_id: 89550[/import]