QuickBox2D Custom Debug Draw

Actionscript:
  1. import com.actionsnippet.qbox.*;
  2. import Box2D.Dynamics.*
  3.  
  4. stage.frameRate = 60;
  5.  
  6. var sim:QuickBox2D = new QuickBox2D(this, {debug:true});
  7.  
  8. // get at the b2DebugDraw instance
  9. var debug:b2DebugDraw = sim.w.m_debugDraw;
  10. debug.m_drawScale = 30.0;
  11. debug.m_fillAlpha = 0.5;
  12. debug.m_alpha = 0.5;
  13. debug.m_lineThickness = 1.0;
  14. debug.m_drawFlags = 0xFF;
  15.  
  16. sim.createStageWalls();  
  17.  
  18. for (var i:int = 0; i<10; i++){
  19.   sim.addBox({x:3 + i, y:3 + i, width:2, height:0.5});
  20. }
  21. sim.addCircle({x:12, y:5, radius:2});
  22.  
  23. sim.start();
  24. sim.mouseDrag();

Note: This snippet requires the QuickBox2D library

This snippet shows an easy way to get at the settings for Box2D's debug renderer.


Have a look at the swf...

This entry was posted in Uncategorized and tagged , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

2 Comments

  1. rishabh govindraj
    Posted November 19, 2009 at 8:53 am | Permalink

    zevan
    i tested this with one of the plys you had posted somewhere and its got a weird result.this one:
    sim.addPoly({x:13, y:5, verts:[[1,0,2,2,1,1.33],[1,0,1,1.33,0,2]], angle: .4, density:1});
    but how do you get the vertices for the polygons?

  2. Posted November 23, 2009 at 12:10 pm | Permalink

    you should check out the points param instead of verts… it’s easier to understand. I’m almost done with a tutorial that explains both points and verts… will post it here when I’m done with it.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*