How to Skin Objects in Box2D

I'm having a great deal of difficulty trying to find a way to skin the ragdoll from the TestBed example or any object in box2d for that matter. All that I am looking to do is attach movie clips to the ragdoll to style it.

I have searched and read for quite a while now and it may be that I am searching for the wrong thing. Surely there must be a simple way of skinning bodies or fixtures in box2DAS3. If you know of any please share, and if you don't have an example can you point me in the right direction?
hi check out the video tutorials here:

http://www.kerp.net/box2d/index.php

he goes into skinning bodies in chapter 17, tho you may need to watch the previous ones to get a decent handle on whats going on.

good luck!
pluginpizzaman wrote:
hi check out the video tutorials here:

http://www.kerp.net/box2d/index.php

he goes into skinning bodies in chapter 17, tho you may need to watch the previous ones to get a decent handle on whats going on.




Thank you but perhaps I wasn't clear with my question. He only covers how to change the styles of the shapes in this tutorial but not how to attach bitmaps to a shape. What I need to do is attach bitmaps of a persons body over a ragdoll, not just change the colors or strokes on the shapes.
Well, I´m really newbie here, but I saw that videos and you can see there how to make it.

This guy makes an sprite and a body, and in the enterFrame where you make the world.Step() you can make a GetPosition().x and GetPosition().y of the body, convert this values to pixels and assing them to the Sprite or MC you want to use as skin. Pretty easy.
I have thoroughly gone through these videos. There is not any skinning involved in them. He only uses b2DebugDraw to draw shapes and give them basic colors and outlines. I need to add movie clips to the shapes and give them actual bitmap image skins.
You´re wrong, there´re skinning tutorials in the videos, I saw them, I´m totally sure.

Anyway, the method is as I said you, make a body, make a Sprite, get the properties of the body and pass them to the Sprite converted.
you are surely wrong.
these videos are must watch for everyone just starting to work with box2d.
Actors and Directors.

As an idea :
An actor is a class that will receive the actual visual part and the b2body as parameters, then tell the visual part to act accordingly to the b2body.

A director tells all the actors to update.

That's about it.
Here is how you skin objects in Box2D:

http://scanplaygames.com/?p=183

The Method looks like this:
Code:

package
{
   import Box2D.Collision.Shapes.b2PolygonShape;
   import Box2D.Common.Math.b2Vec2;
   import Box2D.Dynamics.b2Body;
   import Box2D.Dynamics.b2BodyDef;
   import Box2D.Dynamics.b2FixtureDef;
   import flash.display.Bitmap;
   import flash.display.Sprite;

   /**
    * ...
    * @author ScanPlayGames
    */
   public class Crate extends Sprite
   {
      [Embed(source='crate.jpg')]
      private const crate:Class;

      //box 2d stuff
      private  var boxDef:b2PolygonShape;
      private  var bodyDef:b2BodyDef;
      private  var fixtureDef:b2FixtureDef;
      private  var body:b2Body;   

      //skin
      private var skin:Bitmap;

      public function Crate(_x:Number, _y:Number)
      {
         super();
         x = _x;
         y = _y;

         //create the skin
         skin = Bitmap(new crate());
         skin.height = skin.width = 60;
         addChild(skin);
         skin.x -= 30;
         skin.y -= 30;

         graphics.beginFill(0xff0000, 1);
         graphics.drawRect( -30, -30, 60, 60);
         graphics.endFill();

         boxDef     = new b2PolygonShape();
         bodyDef    = new b2BodyDef();
         fixtureDef = new b2FixtureDef();

         //set the box information
         boxDef.SetAsBox(30 / GameWorld.pixels_per_meter, 30 / GameWorld.pixels_per_meter);
         bodyDef.type = b2Body.b2_dynamicBody;

         fixtureDef.shape = boxDef;
         fixtureDef.density = .05;
         fixtureDef.friction = 0.3;
         fixtureDef.restitution = 0.4;

         //create the body
         body = GameWorld.m_world.CreateBody(bodyDef);
         body.CreateFixture(fixtureDef);
         body.SetPosition(new b2Vec2(_x / GameWorld.pixels_per_meter, _y / GameWorld.pixels_per_meter));
      }

      public function Update():void
      {
         x = body.GetPosition().x * GameWorld.pixels_per_meter;
         y = body.GetPosition().y * GameWorld.pixels_per_meter;
         rotation = body.GetAngle() * ( 180 / Math.PI);
      }
   }
}

Original thread: https://box2d.org/forum/viewtopic.php?t=5126