My guess would be either:
*You have the playerborder object in a scrollview (or table view) and the touch event is being passed onto that, so the scrollview will fire the end event instead of playerborder.
*You have 2 objects on top of each other, both with touch listeners. The touch event is propagating through to the bottom object.
As Rob has suggested, try putting
print(event.phase)
at the start of the function to see what values are being received.
Also, try putting
return true
at the end of the function. This stops the touch event from being passed through to multiple objects.
local playerborder= display.newImage( "Ex.png" ) local function callFun(event) print(event.phase) if(event.phase == "began") then print("began") elseif(event.phase =="ended") then print("ended) end return true end playerborder:addEventListener("touch",callFun)
On a side note, when pasting code into a forum post can you press the < > button in the forum UI (to the left of the speech bubble) and then paste the code into the popup that appears? It makes it easier to read, not a problem with the small function you posted but if the code was longer it can be difficult to parse if it’s not formatted correctly.