QuickBox2D Connect to GroundBody

Actionscript:
  1. import com.actionsnippet.qbox.*;
  2.  
  3. [SWF (backgroundColor=0x000000, width=700, height=600)]
  4.  
  5. var sim:QuickBox2D = new QuickBox2D(this);
  6.  
  7. sim.setDefault({fillColor:0x113366, fillAlpha:0.8, lineColor:0x3355AA});
  8.  
  9. sim.createStageWalls();
  10.  
  11. var boxA:QuickObject = sim.addBox({x:10, y:8, width:4, height:0.5, angularDamping:1});
  12. var boxB:QuickObject = sim.addBox({x:7, y:8, width:3, height:0.25, angle:-.5, angularDamping:1});
  13. var boxC:QuickObject = sim.addBox({x:12, y:2, width:2, height:1});
  14.  
  15. var rev:QuickObject = sim.addJoint({type:"revolute", a:boxA.body, b:sim.w.GetGroundBody()});
  16. // add a red dot to boxA
  17. with (boxA.userData.graphics) lineStyle(), beginFill(0xFF0000), drawCircle(0,0,2);
  18.  
  19. var rev2:QuickObject = sim.addJoint({type:"revolute", a:boxB.body, b:sim.w.GetGroundBody()});
  20. with (boxB.userData.graphics) lineStyle(), beginFill(0xFF0000), drawCircle(0,0,2);
  21.  
  22. sim.start();
  23. sim.mouseDrag();

In order to use gear joints (covered in tomorrows post) you'll need to know how to connect to the ground body...

Check out the swf...

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

2 Comments

  1. Adi
    Posted August 13, 2009 at 7:05 am | Permalink

    I got this errors …

    1046: Type was not found or was not a compile-time constant: b2Vec2.
    1046: Type was not found or was not a compile-time constant: b2Body.

    can you help me make this work ?

    Thanks

  2. Posted August 14, 2009 at 7:09 pm | Permalink

    did you download Box2DFlashAS3 and put it either next to your fla or in your classpath?

    see more info here:
    http://actionsnippet.com/?page_id=1391

One Trackback

  1. [...] 14. ジョイントを空間中の1点と接続する – QuickBox2D Connect to GroundBody [...]

Post a Comment

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

*
*