QuickBox2D Gear Joint

Actionscript:
  1. import com.actionsnippet.qbox.*;
  2. import Box2D.Common.Math.*;
  3.  
  4. [SWF (backgroundColor=0x000000, width=700, height=600)]
  5.  
  6. var sim:QuickBox2D = new QuickBox2D(this,{gravityY:10});
  7.  
  8. sim.setDefault({fillColor:0x113366, fillAlpha:0.8, lineColor:0x3355AA});
  9. sim.createStageWalls();
  10.  
  11. var boxA:QuickObject = sim.addBox({x:10, y:8, width:4, height:0.5, density:10});
  12. var boxB:QuickObject = sim.addBox({x:5, y:5, density:10});
  13. boxB.body.SetLinearVelocity(new b2Vec2(5, 0));
  14.  
  15. var rev1:QuickObject = sim.addJoint({type:"revolute", a:sim.w.GetGroundBody(), b:boxA.body, anchor:boxA.body.GetWorldCenter()})
  16.            
  17. var rev2:QuickObject = sim.addJoint({type:"prismatic", a:sim.w.GetGroundBody(), axis:new b2Vec2(1, 0), b:boxB.body, anchor:boxB.body.GetWorldCenter()})
  18.                                                                                      
  19. sim.addJoint({type:"gear", a:boxA.body, b:boxB.body, joint1:rev1.joint, joint2:rev2.joint});
  20.              
  21. sim.start();
  22. sim.mouseDrag();

Simple gear joint demo - meant to serve as a reference for QuickBox2D...


Have a look at the swf...

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

4 Comments

  1. Posted August 14, 2009 at 6:31 am | Permalink

    new great function and demo !!

    do you think to manage contact events too in your library soon ?

    thx

  2. Jono
    Posted August 14, 2009 at 6:23 pm | Permalink

    I like the way you wrap up Box2DAS3 with QuickBox2D. to be more practical use of this engine, can you demo how you can switch on/off the filter(groupIndex) dynamically? I believe in the real world projects(like game) you’d like to need this sort of flexibility!

  3. Posted August 14, 2009 at 6:48 pm | Permalink

    I have a simple idea for making contact events a bit easier - will try it in the next release I think. I have a demo somewhere that switches the groupIndex on and off based on position - I’ll dig it up and post it in the next day or two.

  4. Aru123
    Posted July 30, 2010 at 3:00 am | Permalink

    I am creating truck using Quickbox 2d. What type of joint, i need to use to connect front and back part of truck?

One Trackback

  1. [...] 15. ギアジョイント(GearJoint)を作る – QuickBox2D Gear Joint [...]

Post a Comment

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

*
*