Syntax to check which physics bodies collide using categoryBits and maskBits

If I am using categoryBits and maskBits to separate my objects into two categories, how would I write code to do different things depending on which categories collide? [import]uid: 106739 topic_id: 19698 reply_id: 319698[/import]

This post might help.
http://developer.anscamobile.com/forum/2010/10/25/collision-filters-helper-chart [import]uid: 70847 topic_id: 19698 reply_id: 76190[/import]

I’ve seen that (or I wouldn’t be posting such a question). It says how to apply the filters to the objects, but not what code is needed to check what categories the colliding objects are. [import]uid: 106739 topic_id: 19698 reply_id: 76194[/import]

You can assign your own attribute to your objects and check for the attribute in the collision handler

[lua]…
object1.objectType = “enemy”
object2.objectType = “reward”

local function onCollision(event)
local objectHit = event.other;

if (objectHit.objectType == “enemy”) then
– do something

elseif (objectHit.objectType == “reward”) then
– do something else
end
end[/lua] [import]uid: 70847 topic_id: 19698 reply_id: 76195[/import]

I was hoping I could avoid that, as I will be spawning A LOT of objects in the actual game code, but if theres no other choice, I will do that. (a lot means 30-40+ ) [import]uid: 106739 topic_id: 19698 reply_id: 76196[/import]