Hi,
I have several different objects that are connected to the same EventListener for "tap". How do I know which one was tapped? If their is now ways of finding out which was tapped, is their a way to pass parameters to the event?
Thank you in advance.
you can make one function and make sure every object has theirs .name like this:
1
2
3
4
5
6
7
8
9
10
| local obj1 = display.newRect(0,0,50,50)
obj1.name = "obj1"
local function foo(self,event)
if event.phase == "ended" then
print(self.name)
end
obj1.touch = foo
obj1:addEventListener("touch", obj) |
Have a look at the DragMeMultitouch sample code. This clearly shows how multiple objects are handled by a single event listener.
-David