I am trying this but with no success. My paddle just hangs down limply. I cant get the paddle to turn whatsoever using a motor.
I think it may have to do with me using a user defined image for the flipper.
Do I have to do anything special in the update routine to update the flipper image beside what I am doing already (see below)?
Do I have to do anything in the update routine to update joints?
(I am using Flash box2d V1.4.3.1)
bd = new b2BodyDef();
def = new b2BoxDef();
def.density = 1.0;
def.extents.Set(73/2, 12/2);
bd.userData = new FlipperIMG();
bd.userData.width = 73;
bd.userData.height = 12;
bd.AddShape(def);
bd.position.Set(314,544);
bd.rotation = 45 / (180/Math.PI);
body=m_world.CreateBody(bd);
body.m_mass=def.density;
addChild(bd.userData);
jd = new b2RevoluteJointDef();
jd.anchorPoint.Set(314,544);
jd.body1 = body;
jd.body2 = ground;
jd.enableMotor=true;
jd.motorSpeed = -1.0 * Math.PI;
jd.motorTorque = 500000000.0;
LeftPaddleJoint=m_world.CreateJoint(jd);
My update routine:
m_world.Step(m_timeStep, m_iterations);
// Go through body list and update sprite positions/rotations
for (var bb:b2Body = m_world.m_bodyList; bb!=null; bb = bb.m_next)
{
if (bb.m_userData is Sprite)
{
bb.m_userData.x = bb.m_position.x;
bb.m_userData.y = bb.m_position.y;
bb.m_userData.rotation = bb.m_rotation * (180/Math.PI);
}
}
Please help!
thanks.
I think it may have to do with me using a user defined image for the flipper.
Do I have to do anything special in the update routine to update the flipper image beside what I am doing already (see below)?
Do I have to do anything in the update routine to update joints?
(I am using Flash box2d V1.4.3.1)
bd = new b2BodyDef();
def = new b2BoxDef();
def.density = 1.0;
def.extents.Set(73/2, 12/2);
bd.userData = new FlipperIMG();
bd.userData.width = 73;
bd.userData.height = 12;
bd.AddShape(def);
bd.position.Set(314,544);
bd.rotation = 45 / (180/Math.PI);
body=m_world.CreateBody(bd);
body.m_mass=def.density;
addChild(bd.userData);
jd = new b2RevoluteJointDef();
jd.anchorPoint.Set(314,544);
jd.body1 = body;
jd.body2 = ground;
jd.enableMotor=true;
jd.motorSpeed = -1.0 * Math.PI;
jd.motorTorque = 500000000.0;
LeftPaddleJoint=m_world.CreateJoint(jd);
My update routine:
m_world.Step(m_timeStep, m_iterations);
// Go through body list and update sprite positions/rotations
for (var bb:b2Body = m_world.m_bodyList; bb!=null; bb = bb.m_next)
{
if (bb.m_userData is Sprite)
{
bb.m_userData.x = bb.m_position.x;
bb.m_userData.y = bb.m_position.y;
bb.m_userData.rotation = bb.m_rotation * (180/Math.PI);
}
}
Please help!
thanks.