QuickBox2D Joint Skinning

Well… while on the topic of skinning I figured I’d post something I’ve been meaning to post for awhile. Currently, joint skinning leaves something to be desired in QuickBox2D. This is because I haven’t had the need to skin many joints … and also because with joints like pulley, prismatic, revolute etc… I’m not entirely sure what the best skinning solution even is… For instance, on a pulley you probably don’t want three duplicate MovieClips used for the skin. Anyway, early on in my Box2D experimentation I needed distance joint skins so that feature has been around since maybe alpha 108…

It’s pretty simple, Check out the demo and code below:

import com.actionsnippet.qbox.*;
 
[SWF(width = 800, height = 600, backgroundColor = 0xFFFFFF, frameRate=60)]

var sim:QuickBox2D = new QuickBox2D(this, {debug:false});

sim.createStageWalls({fillColor:0xFFFFFF});
 
var circleA:QuickObject = sim.addCircle({x:3, y:3, radius:1, skin:CircleSkin});
var circleB:QuickObject = sim.addCircle({x:6, y:6, radius:0.5, skin:CircleSkin});

sim.addJoint({type:"distance", a:circleA.body, b:circleB.body, skin:JointSkin});

sim.start();
sim.mouseDrag();


Check out the swf here…

Download the fla here…

11 comments

  1. Nice new additions, I’ll be sure to update to 1.1.

    I’ve been meaning to ask this (probably silly) question but is there a way to make a solid sleep at runtime? like if it triggers a contact make it so that it doesnt trigger another one next.

    Its just that I have this silly bug in one of my games that makes a solid trigger 2 events when it collides even though the second collision is with a solid that it never touches.

    Thanks, keep it up!

  2. Very nice work here πŸ™‚
    Thank you for sharing. I am just starting to play around with Box2D for fun and found this in one of their forums. Glad I did cause this simplyfy stuffs.

    Though I would like to suggest a feature if it’s possible the one similar to
    Box2DConcaveArc

    Thank you.

  3. Yeah… Box2DConcaveArc is cool – but its super buggy. Writing custom shapes for Box2D is pretty tricky. For now you can use polygons:

    https://actionsnippet.com/?p=1471

    I may getting around to doing some real Box2D patches like that, but as of now I’m focusing on more simple features for QuickBox2D πŸ˜‰

  4. True… it’s buggy… sometimes it slows down the processor πŸ™
    I think the idea is to get an inverted circle collision instead of listening for the poly to collide with the arc, it should draw a circle from the arc’s surface and listens when the item falls out from the circle (into the arc)… hmm.

    I am still looking through your examples. Maybe it’s already in there somewhere. Thanks again πŸ™‚

  5. I can’t seem to get my distance joints to rotate. Instead they just scale. For example, if point A is at 0,0 and point B is a 1,1, the joint will be a square that’s 1×1 (top left and bottom right corners are where point A and B are) rather than staying at its normal scale and rotating 45 degrees. Does that make sense? Thanks!

  6. Hey Lance… yeah that’s the way its setup… since the distance between the rigid bodies can vary, the joint skin is scaled in accordance with that…. if you post a link to your file I’d be glad to give you a suggestion regarding how to deal with your specific skinning needs… I’m sure there is a way to get what you want… may just not be the most intuitive thing πŸ™‚

Leave a Reply

Your email address will not be published. Required fields are marked *