multiple display.newImage

hi,

i don’t understand why i clic, two object “cres” appears while I do not want one

thanks for you response

function appears ()     local xposition = math.random( 1, 250 )     local yposition = math.random( 1,250 )     local cres = display.newImage ("crate.png", xposition, yposition )     physics.addBody( cres, { density=1, friction=10, bounce=20 } ) end Runtime:addEventListener( "touch", appears )

Hi @espace3d,

The “touch” listener contains several phases including “began”, “moved”, and “ended” which you must handle properly in conditional logic. The following tutorial is a good introduction of this concept:

http://coronalabs.com/blog/2013/10/01/tutorial-taptouch-anatomy/

Take care,

Brent

Hi Brent,

Thank you for this documentation…i didn’t know this part of the site.

it’s very informative.

return true it’s the solution im my case.

Good day :wink:

Hi @espace3d,

The “touch” listener contains several phases including “began”, “moved”, and “ended” which you must handle properly in conditional logic. The following tutorial is a good introduction of this concept:

http://coronalabs.com/blog/2013/10/01/tutorial-taptouch-anatomy/

Take care,

Brent

Hi Brent,

Thank you for this documentation…i didn’t know this part of the site.

it’s very informative.

return true it’s the solution im my case.

Good day :wink: