Hi,
I tried for a while but I didn’t find a solution to this:
Say I have several small images on the screen. And i want them to print their position when they get tapped.
It’s easy for one single image:
[lua]circle = display.newCircle(20, 20, 20)
function circle:tap(event)
print(circle.x…"/"…circle.y)
end
circle:addEventListener(“tap”, circle)[/lua]
But what if I have something like this:
[lua]circle1 = display.newCircle(20, 20, 20)
circle2 = display.newCircle(60, 20, 20)
circle3 = display.newCircle(100, 20, 20)
circle4 = display.newCircle(140, 20, 20)
circle5 = display.newCircle(180, 20, 20)[/lua]
I don’t want to define five different listeners since they would all do the same. So is there a way to define the listener once and reuse it in multiple tap-events? [import]uid: 24216 topic_id: 5732 reply_id: 305732[/import]
[import]uid: 24216 topic_id: 5732 reply_id: 19631[/import]