I am working with box2dweb and i am trying to make a function, that would add instructions how to draw a 'body' based on the 'body' shape.
That is: When received a 'b2BodyDef' get the shape, and with external information, get the shape specifications. To do this i need to cast 'b2Shape' back to 'b2CircleShape'.
I guess with C++ this would be something like
 b2CircleShape* shape_circle = dynamic_cast< (b2CircleShape*) >( shape );
How do i do similar thing with javascript? I do know there are tons of other ways to do this (like pass the wanted radius on this example as parameter) but i would like to do what i feel like right and not a hack.
function Add_new_drawable_object_to_world( body, type )
{
      GLOBAL_world_objects.push( body );
      var s = new Sprite();
      if ( type == OBJECT_TYPE_PLAYER )
      {
         s.graphics.beginFill ( 0x2222ff, 0.6);
         var b2CircleShape   = Box2D.Collision.Shapes.b2CircleShape;
         var fixture_list = body.GetFixtureList();
         var shape        = fixture_list.GetShape() ;
         // FIXME: TypeError: shape.GetRadius is not a function 
          var radius = shape.GetRadius();
         // here i would draw fancy circle with 'radius'
And earlier i have:
   // Create player
   var player     = new b2FixtureDef();   // ball fixture definition
   player.shape   = new b2CircleShape();
   player.density = 0.5;
   player.shape.SetRadius( 0.2 );
   var bodyDef = new b2BodyDef();
   bodyDef.type = b2Body.b2_dynamicBody;
   bodyDef.position.Set( 0.0, 0.0 );
   var body = GLOBAL_world.CreateBody(bodyDef);
   body.CreateFixture( player );
   Add_new_drawable_object_to_world( body, OBJECT_TYPE_PLAYER );
 
    