Hi,
I'm using a rope type system, which uses revolute joints to connect bodies containing polygon shapes (I draw into those with the graphics API, and on 2 or 3 of the polygons I add a MovieClip to the shape def so the rope ends up looking like objects are 'tied' to it, but those don't need to be physics-realistic).
The rope is for a left-hand navigation menu on a site, which is to have a bit of a subtle swing to it, and have the menu buttons dotted down the rope.
I'm having trouble moving the rope into a starting position without having to make that the sort of default state/position for the rope.
In a loop of, say, 32 parts of rope, I do:
bodyDef.position.Set(0, i*0.5)
// draw bodyDef here with userData = new Sprite etc.
anchor = new b2Vec2(bodyDef.position.x, bodyDef.position.y);
jointDef.Initialize(prev_body, body, anchor);
m_world.CreateJoint(jointDef);
prev_body = body;
As you can see from the Set(0, i*0.5), I'm originally laying out the bodies vertically, and putting their anchors in the same positions (that seemed to work fine, probably because all the segments are small). I know that I could start the rope at a 90 degree angle, as in horizontally, by doing position.Set(i*0.5, 0), but that means I have to calculate these positions individually. I want to put the physics system in place, then move the rope. I'd like to know how to do this in any number of ways (with some pseucode or just an explanation). I've tried applying a linear velocity to every one of the bodies as I create them, which does set the rope moving, but it doesn't look great. I think what I'd like to do, ideally, is be able to obtain a handle to one of the lower segments of the rope (that's not what I'm having trouble with), move it up and out of the top left of the screen, farther horizontally than vertically, and actually force the rope to that state - as if someone's held the rope up out of view, and lets go of it when the app starts.
I see things like the Advance method, and SetXForm, but I'm not having much luck with them, probably because I'm using them all wrongly.
Can anyone help?
Thanks.
I'm using a rope type system, which uses revolute joints to connect bodies containing polygon shapes (I draw into those with the graphics API, and on 2 or 3 of the polygons I add a MovieClip to the shape def so the rope ends up looking like objects are 'tied' to it, but those don't need to be physics-realistic).
The rope is for a left-hand navigation menu on a site, which is to have a bit of a subtle swing to it, and have the menu buttons dotted down the rope.
I'm having trouble moving the rope into a starting position without having to make that the sort of default state/position for the rope.
In a loop of, say, 32 parts of rope, I do:
bodyDef.position.Set(0, i*0.5)
// draw bodyDef here with userData = new Sprite etc.
anchor = new b2Vec2(bodyDef.position.x, bodyDef.position.y);
jointDef.Initialize(prev_body, body, anchor);
m_world.CreateJoint(jointDef);
prev_body = body;
As you can see from the Set(0, i*0.5), I'm originally laying out the bodies vertically, and putting their anchors in the same positions (that seemed to work fine, probably because all the segments are small). I know that I could start the rope at a 90 degree angle, as in horizontally, by doing position.Set(i*0.5, 0), but that means I have to calculate these positions individually. I want to put the physics system in place, then move the rope. I'd like to know how to do this in any number of ways (with some pseucode or just an explanation). I've tried applying a linear velocity to every one of the bodies as I create them, which does set the rope moving, but it doesn't look great. I think what I'd like to do, ideally, is be able to obtain a handle to one of the lower segments of the rope (that's not what I'm having trouble with), move it up and out of the top left of the screen, farther horizontally than vertically, and actually force the rope to that state - as if someone's held the rope up out of view, and lets go of it when the app starts.
I see things like the Advance method, and SetXForm, but I'm not having much luck with them, probably because I'm using them all wrongly.
Can anyone help?
Thanks.