Problem:Touched Icon above Touched Object

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? [import]uid: 65906 topic_id: 17313 reply_id: 317313[/import]

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 = falselocal 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 trueendRuntime:addEventListener( "touch", onScreenTouch )[/code]Hope that helps get you started! [import]uid: 52430 topic_id: 17313 reply_id: 65555[/import]

@jonathanbeebe
thanks for your advice.
However, I still cannot solve the problem.
When I touched the object, I want to show touch icon above that object.

I have question about object:addEventListener(“touch”,…)
and Runtime:addEventListener( “touch”, …)
Which is better ?(such as memory, control…)

I set touch icon’s touch event in Runtime Event while
I set object’s touch event in Object Event.

I still try to find the solution. [import]uid: 65906 topic_id: 17313 reply_id: 65637[/import]

I can’t quite understand what you are trying to do - so I can’t comment on the initial question beyond what Jon said.

However I can tell you that adding the listener to the object rather than Runtime is definitely the way to go - then it is only fired when you touch the object rather than being called anytime you touch anything, as it would be with Runtime.

Peach :slight_smile: [import]uid: 52491 topic_id: 17313 reply_id: 65741[/import]

@peach
So, addEventListener to object is better?

For what I want to do is similar to samurai fruit blade.
When the blade touched to fruit, the fruit was sliced.

My touch icon = blade
My object = fruit

But my touch-icon does not appear when I touched object though object’s touch function works.

Is it more clear?
Sorry for my bad explanation. [import]uid: 65906 topic_id: 17313 reply_id: 65743[/import]

Oh right, OK, so you’re sliding your finger around the screen, or swiping, or whatever - and when you touch an object (just like how the fruit is sliced in samurai fruit) you want something to happen - like an icon to appear.

Adding a “touch” listener on the object should work fine.

Do you have any code you can share to try and show the problem?

Peach :slight_smile: [import]uid: 52491 topic_id: 17313 reply_id: 65757[/import]

@peach
thanks for your advice.
I have already tried. Well…
I found that if in touch event does not return true,
everything is fine.
[import]uid: 65906 topic_id: 17313 reply_id: 67276[/import]