Hi,
I want to compare/identify two colliding objects.
For that i added a contact listener instance and overrided the Add function.
Add function uses instance of b2ContactPoint as argument.
From this point instance, i can get the 2 shapes colliding: shape1 and shape2.(which are the properties of this class)
From this information how can i compare it with another colliding body?
I have an array of boxes (which are QuickObjects)
So, i am comparing all the objects in the array with both the shape1 and shape2 (which i got from the point) because one of these is the object in the box array.
So, my question is how do i make the comparison i.e. what should i compare?
i tried to do this, but it doesn't work:
//function call
onCollision(point.shape1.m_body, point.shape2.m_body);
//function declaration
onCollision(collidingBody1:b2Body, collidingBody2:b2Body):void
{
for each(var box:TargetBox in TargetBox)
{
if (box.__box.body == collidingBody1 || box.__box.body == collidingBody2)
{
//do something
}
}
}
Please help!
TIA
I want to compare/identify two colliding objects.
For that i added a contact listener instance and overrided the Add function.
Add function uses instance of b2ContactPoint as argument.
From this point instance, i can get the 2 shapes colliding: shape1 and shape2.(which are the properties of this class)
From this information how can i compare it with another colliding body?
I have an array of boxes (which are QuickObjects)
So, i am comparing all the objects in the array with both the shape1 and shape2 (which i got from the point) because one of these is the object in the box array.
So, my question is how do i make the comparison i.e. what should i compare?
i tried to do this, but it doesn't work:
//function call
onCollision(point.shape1.m_body, point.shape2.m_body);
//function declaration
onCollision(collidingBody1:b2Body, collidingBody2:b2Body):void
{
for each(var box:TargetBox in TargetBox)
{
if (box.__box.body == collidingBody1 || box.__box.body == collidingBody2)
{
//do something
}
}
}
Please help!
TIA