I need to retrieve the size of an actor's collision shape.
My first try, based on a Box2D forum post was:
private function getShapeSize(target:Actor, size:Rectangle):Rectangle
{
for(var f:b2Fixture = target.getBody().m_fixtureList; f; f = f.m_next)
{
//var shape:b2Shape = target.getBody().m_fixtureList.m_shape;
var shape:b2Shape = f.m_shape;
print("m_type=" + shape.m_type);
if(shape.m_type == b2Shape.e_circle)
{print("circle");
size.width = (shape as b2CircleShape).m_radius;
size.height = size.width;
}
else if(shape.m_type == b2Shape.e_polygon)
{
print("poly");
var vertex:V2 = (shape as b2PolygonShape).GetVertex(1);
size.width = vertex.x;
size.height = vertex.y;
}
}
return size;
}
b2Shape.m_type returns e_typeCount.
Has anyone any idea on how to get a b2Shape size?