Matching Objects

If someone could point me to, or post how to do the following, that would be awesome:

When an object collides with another object if both are the same “type” (e.g. same color) then do X, such as play a sound, if not play Y sound.  (I’ll be doing this for drag and drop matching of objects)

Thanks!

Just assign a “type” property to your object. Assuming you have an object variable named myObj, just do something like this:

myObj.type=“cow” – This can be whatever identifying value you want.

Then in the collision event, just check the type value of each object:

if (objHit.type == myObj.type) then

    – They’re the same object type.

end

EDIT: I’m not sure if type is a reserved word or not, so maybe use a more unique property name, like mytype or something.

Thanks sheppe!

Just assign a “type” property to your object. Assuming you have an object variable named myObj, just do something like this:

myObj.type=“cow” – This can be whatever identifying value you want.

Then in the collision event, just check the type value of each object:

if (objHit.type == myObj.type) then

    – They’re the same object type.

end

EDIT: I’m not sure if type is a reserved word or not, so maybe use a more unique property name, like mytype or something.

Thanks sheppe!