Touch Event Ended Phase Not Happening

Hello everybody… I am new to LUA and Corona, so please forgive me if this is obvious.  I have setup a touch event for a group of objects in a table. This works great as long as the user is not sliding their finger very fast. As soon as the user goes too fast event.phase == “ended”  fails to fire. My object is then left in limbo as I have not figured out a way to determine that this has occurred  If the finger is moving at reasonable speed everything works fine. I have also tried to put in an event.phase == “cancelled”. That does not fire when this occurs. So two questions:

 

#1… Is this a bug? Would you normally expect an ended to always fire even if the system cannot track the touch anymore?

#2. Regardless of whether it is a bug or not, How do I determine if this happened so I can reset things?

 

Thanks

 

Code below:

function freeTileGroupHandler (event) tileNbr = event.target if event.phase == "began" then tileNbr.markX = tileNbr.x tileNbr.markY = tileNbr.y freeTileNbr = tileNbr.myName elseif event.phase == "moved" then tileNbr.x = (event.x - event.xStart) + tileNbr.markX tileNbr.y = (event.y - event.yStart) + tileNbr.markY elseif event.phase == "ended" then -- DO LOTS OF STUFF HERE end return true end -- Table below has many display.groups loaded into it "a" is part of a loop that adds an event listener for each object in the table. The -- event handler above figures out which item was touched with event.target gameData.currentTileSetPlayer1[a].graphics.freeGroup:addEventListener("touch",freeTileGroupHandler)

 

 

as far as I know, the “cancelled” event is only fired when focus has been set. did you try that? you probably don’t get the ended phase, since you did not release on the object, but beside I guess?

 


        display.getCurrentStage():setFocus(yourObject);  
        yourObject.isFocus = true;

That Fixed it… Thanks Much!

Mike

as far as I know, the “cancelled” event is only fired when focus has been set. did you try that? you probably don’t get the ended phase, since you did not release on the object, but beside I guess?

 


        display.getCurrentStage():setFocus(yourObject);  
        yourObject.isFocus = true;

That Fixed it… Thanks Much!

Mike

Hi @dingo,

I’m having a similar problem, and have tried implementing your fix. Can you see where I went wrong?

[lua]

    local function onRowTouch( event )

        local phase = event.phase

        local row = event.row

        

        if “began” == phase or “moved” == phase and not row.isFocus then

            display.getCurrentStage():setFocus(row)

            row.isFocus = true

        elseif “ended” == phase and row.isFocus then

            row.isFocus = false

           – other stuff

            return true

        end

    end

[/lua]

Btw, I solved my problem, but it has to do with the fact that I was using a tableView. Instead of “ended” I had to use “released” for the end of my touch event. I.e. not really applicable to your problem, sorry!

Hi @dingo,

I’m having a similar problem, and have tried implementing your fix. Can you see where I went wrong?

[lua]

    local function onRowTouch( event )

        local phase = event.phase

        local row = event.row

        

        if “began” == phase or “moved” == phase and not row.isFocus then

            display.getCurrentStage():setFocus(row)

            row.isFocus = true

        elseif “ended” == phase and row.isFocus then

            row.isFocus = false

           – other stuff

            return true

        end

    end

[/lua]

Btw, I solved my problem, but it has to do with the fact that I was using a tableView. Instead of “ended” I had to use “released” for the end of my touch event. I.e. not really applicable to your problem, sorry!