Game Development Reference
In-Depth Information
debugSprite is just a sprite; the canvas used to display debug draw data.
addChild(debugSprite);
Debug draw sprite is added to Display List, ready to be shown on stage.
debugDraw.SetSprite(debugSprite);
The SetSprite method tells which sprite will be used to display
debug draw.
debugDraw.SetDrawScale(worldScale);
As we are converting meters to pixels, we need to tell debug draw the
draw scale we are using.
debugDraw.SetFlags(b2DebugDraw.e_shapeBit);
The SetFlags method allows us to decide which kind of physic entities we
are going to represent with debug draw. At this moment we only need to
draw the shapes.
debugDraw.SetFillAlpha(0.5);
The SetFillAlpha method is used just for an aesthetic purpose. This
way shape's outline will be fully opaque while their fill color will be
semitransparent. This makes the debug draw output more understandable.
world.SetDebugDraw(debugDraw);
Finally, we assign the debug draw we just created to the world.
4. Now it's time to test your movie, and you should finally see the ball:
 
Search WWH ::




Custom Search