How can you set up one function that receives events from different objects on the screen? I don’t want to create a different function every single touch event. Here’s what I have, but it doesn’t work:
[code]
local obj = display.newGroup();
function obj:touch(e)
local t = e.target;
if(e.phase == “ended”) then
print("cat touched: " … t.name);
end
return true;
end
local cat1 = display.newImageRect(“images/cat1.png”, 15, 16);
cat1.name = “cat1”;
obj:insert(cat1);
cat1:addEventListener(“touch”, ???);
local cat2 = display.newImageRect(“images/cat2.png”, 15, 16);
cat2.name = “cat2”;
obj:insert(cat2);
cat2:addEventListener(“touch”, ???);
[/code] [import]uid: 52127 topic_id: 9455 reply_id: 309455[/import]