Game Development Reference
In-Depth Information
bodyDef.type=b2Body.b2_staticBody;
var polygonShape:b2PolygonShape=new b2PolygonShape();
polygonShape.SetAsBox(320/worldScale,10/worldScale);
fixtureDef.shape=polygonShape;
var theFloor:b2Body=world.CreateBody(bodyDef);
theFloor.CreateFixture(fixtureDef);
var debugDraw:b2DebugDraw=new b2DebugDraw();
var debugSprite:Sprite=new Sprite();
addChild(debugSprite);
debugDraw.SetSprite(debugSprite);
debugDraw.SetDrawScale(worldScale);
debugDraw.SetFlags(b2DebugDraw.e_shapeBit);
debugDraw.SetFillAlpha(0.5);
world.SetDebugDraw(debugDraw);
addEventListener(Event.ENTER_FRAME,updateWorld);
}
I am assigning the attributes only once, so both bodies will have the same fixture
attributes. We'll deal a lot with ixture attributes during the course of this topic,
so at the moment let's just make this ball bounce.
Test the movie and you should see the ball bouncing.
Congratulations! You just completed your first real Box2D project, and now you
are able to create basic shapes and assign their attributes and properties.
It's time to create something closer to a game.
 
Search WWH ::




Custom Search