Big Problem ... Ended phase on touch event not fired

I apologize. I was not aware that bug reports were classified. Here’s my main.lua. [lua]local n_SwipeLength = 150
local n_radius = 140
local n_legitTouch = false
local shape_selection_body
local shape_selection_head
local centerX = display.contentWidth/2
local centerY = display.contentHeight/2

local InterfaceEvent = function(event)
print(event.phase)
if event.phase == ‘began’ then
n_legitTouch = true

shape_selection_head = display.newCircle(0, 0, 20)
shape_selection_head:setFillColor(255, 255, 255)
shape_selection_head:translate(centerX,centerY)

elseif event.phase == ‘moved’ and n_legitTouch == true then
if(shape_selection_body ~= nil) then shape_selection_body:removeSelf() end

local cursorX = event.xDist * n_radius
local cursorY = event.yDist * n_radius
local cursorLength = math.sqrt(cursorX*cursorX + cursorY*cursorY)

shape_selection_body = display.newLine(centerX, centerY, centerX+cursorX, centerY+cursorY)
shape_selection_body:setColor(180, 180, 180)
shape_selection_body.width=5
if(shape_selection_head ~= nil) then
shape_selection_head.x = centerX+cursorX
shape_selection_head.y = centerY+cursorY
end
elseif (event.phase == ‘ended’ or event.phase == ‘cancelled’) and n_legitTouch == true then
print(event.xDist…’, '…event.yDist)
if(shape_selection_body ~= nil) then shape_selection_body:removeSelf() end
shape_selection_body = nil
if(shape_selection_head ~= nil) then shape_selection_head:removeSelf() end
shape_selection_head = nil

n_legitTouch = false
end
end

local screenTouch = function(event)
if(event.phase == ‘began’) then
InterfaceEvent({phase=‘began’})
elseif(event.phase == ‘moved’) then
local xDist = event.x - event.xStart
local yDist = event.y - event.yStart
if xDist < -n_SwipeLength then xDist = -n_SwipeLength end
if yDist < -n_SwipeLength then yDist = -n_SwipeLength end
if xDist > n_SwipeLength then xDist = n_SwipeLength end
if yDist > n_SwipeLength then yDist = n_SwipeLength end
xDist = xDist/n_SwipeLength
yDist = yDist/n_SwipeLength

InterfaceEvent({phase=‘moved’, xDist=xDist, yDist=yDist})
elseif(event.phase == ‘ended’ or event.phase == ‘cancelled’) then
local xDist = event.x - event.xStart
local yDist = event.y - event.yStart
if xDist < -n_SwipeLength then xDist = -n_SwipeLength end
if yDist < -n_SwipeLength then yDist = -n_SwipeLength end
if xDist > n_SwipeLength then xDist = n_SwipeLength end
if yDist > n_SwipeLength then yDist = n_SwipeLength end
xDist = xDist/n_SwipeLength
yDist = yDist/n_SwipeLength

InterfaceEvent({phase=‘ended’, xDist=xDist, yDist=yDist})
end
end

Runtime:addEventListener( “touch”, screenTouch )[/lua]
A little more complicated than necessary, but demonstrates the problem. If you touch with one finger, drag, touch with another finger, then remove the first and second fingers, there will be no ended phase. I know this because the circle shape_selection_head is never removed, and just gets assigned to a new circle when the next began phase appears.

I have modified the code since, to test for n_legitTouch in the began phase, so that I can get rid of the rogue circles. But still, this behavior seems buggy.

Are you testing with iOS or Android? I can only test with Android. [import]uid: 70391 topic_id: 19348 reply_id: 75121[/import]

Oh, I did not see your previous post. Yeah, maybe this is just an Android bug.

I wonder what the OP was using. [import]uid: 70391 topic_id: 19348 reply_id: 75122[/import]

Aha! Yes, now it’s confirmed…it’s an Android thing!

I took your code and ran it on my iOS devices (iPad, iPod Touch) with no problems at all.

When I run it on my Galaxy Player (Android 2.2) I get the problem you describe.
bummer.
[import]uid: 70847 topic_id: 19348 reply_id: 75123[/import]

finally ?? its just appears in android os ?? does ios behaves in another way ?? [import]uid: 74537 topic_id: 19348 reply_id: 75259[/import]

@test driver
Yes, this problem only exists on Android. iOS sends the “ended” event as it should. I’m guessing that this might be an Android bug, and not a bug in Corona.

There are other issues that are Android specific as well, for example when playing audio-effects. On most Android platforms you have a significant audio delay (up to 0.5 seconds) before the sound is played if you use the OpenAL functions of the Audio API (audio.play() etc). This is an Android issue and not a Corona issue.
The workaround is to use the Multimedia API instead to play sound-effects. There is still an audio delay, but it’s acceptable. The issue with the Multimedia API is that only one sound can be playing at any given time, which is not good for action games when you have a lot of sounds happening at the same time. The best thing is to always use the Audio API which can handle up to 32 simultaneous sounds, but as said above, it’s not acceptable on Android.
On iOS there are no problematic audio delays.
[import]uid: 70847 topic_id: 19348 reply_id: 75266[/import]

thank you @ingemar for this description :slight_smile:
[import]uid: 74537 topic_id: 19348 reply_id: 75271[/import]

so was there any resolution to this bug in the end? finding a similar issue… [import]uid: 133319 topic_id: 19348 reply_id: 113171[/import]

So what to do? You fix it someday? [import]uid: 138593 topic_id: 19348 reply_id: 123193[/import]

So what to do? You fix it someday? [import]uid: 138593 topic_id: 19348 reply_id: 123193[/import]

@GamingStudio17
you can enable mutlitouch this will improve touch
on android mobiles [import]uid: 74537 topic_id: 19348 reply_id: 125038[/import]

@GamingStudio17
you can enable mutlitouch this will improve touch
on android mobiles [import]uid: 74537 topic_id: 19348 reply_id: 125038[/import]