Object in group

I have multiple objects inside of two different display groups they all use the same event listener, when inside of the event listener is there a way to test if an object is in displayGroupA or displayGroupB?

Thanks

The easiest way is it just give them an additional property when you add the to the group, and then check that property:

local myObject = display.whatever() myObject.groupName = "displayGroupA" displayGroupA:insert(myObject) local myOtherObject = display.whatever() myOtherObject.groupName = "displayGroupB" displayGroupB:insert(myOtherObject) local function doStuff(e) if e.target.groupName == "displayGroupA" then print("I'm in group A") else print("I'm in group B") end end

The easiest way is it just give them an additional property when you add the to the group, and then check that property:

local myObject = display.whatever() myObject.groupName = "displayGroupA" displayGroupA:insert(myObject) local myOtherObject = display.whatever() myOtherObject.groupName = "displayGroupB" displayGroupB:insert(myOtherObject) local function doStuff(e) if e.target.groupName == "displayGroupA" then print("I'm in group A") else print("I'm in group B") end end