I tried to make the touched icon appeared every times that touch event occurred (touch event handle function which does not return true).
In touched object has touch event handle function which returns true so 1 touch per 1 object.
However, I found touched icon always disappear when I touched the object. Even though, I add object before touched icon in camera.
.....Any idea?
You could create your image object, and set the isVisible property to false. During the "began" phase, you could set to to true. Then, during the "ended" phase of a touch listener, hide it.
Example:
local touchedIcon = display.newImage( "image.png" )
touchedIcon.isVisible = false
local function onScreenTouch( event )
if event.phase == "began" then
touchedIcon.isVisible = true
elseif event.phase == "ended" or event.phase == "cancelled" then
touchedIcon.isVisible = false
end
return true
end
Runtime:addEventListener( "touch", onScreenTouch )
views:1321 update:2011/11/5 17:18:39