Hi all, I decided to give myself a project to learn all of this. I settled on a quick BrickBreaker (Break Out) clone. I have the physics setup so that the world has zero gravity and the ball doesn't lose any speed from contact with the walls. I even made a simple box at the bottom for the paddle.
When it came time to make the paddle slide left and right I was unsure if I should use the MouseJoint or just move the box to the the current mouse location.
I'm deconstructing the TestBed.fla to lay everything out. I wasn't sure how to arbitrarily just move the x coords of the paddle so I decided to rewrite the MouseDrag function to ONLY attach itself to the the paddle I made. But I don't know how to rewrite this line...
var body:b2Body = GetBodyAtMouse();
to instead reference the "body" of my paddle which was declared earlier as...
barShape = new b2BoxDef();
barBodyDef = new b2BodyDef();
barBodyDef.AddShape(barShape);
barShape.density = 1;
barShape.friction = 1;
barShape.restitution = 0;
barShape.extents.Set((50) / m_physScale, (10) / m_physScale);
barBodyDef.position.Set((640 / 2) / m_physScale, (480 - 10) / m_physScale);
m_world.CreateBody(barBodyDef);
Let me know if I'm making no sense or am not thinking of this the right way. Also if anyone thinks I should just move the paddle to the mouse x position to avoid the lag of using a joint. Thanks! rob
When it came time to make the paddle slide left and right I was unsure if I should use the MouseJoint or just move the box to the the current mouse location.
I'm deconstructing the TestBed.fla to lay everything out. I wasn't sure how to arbitrarily just move the x coords of the paddle so I decided to rewrite the MouseDrag function to ONLY attach itself to the the paddle I made. But I don't know how to rewrite this line...
var body:b2Body = GetBodyAtMouse();
to instead reference the "body" of my paddle which was declared earlier as...
barShape = new b2BoxDef();
barBodyDef = new b2BodyDef();
barBodyDef.AddShape(barShape);
barShape.density = 1;
barShape.friction = 1;
barShape.restitution = 0;
barShape.extents.Set((50) / m_physScale, (10) / m_physScale);
barBodyDef.position.Set((640 / 2) / m_physScale, (480 - 10) / m_physScale);
m_world.CreateBody(barBodyDef);
Let me know if I'm making no sense or am not thinking of this the right way. Also if anyone thinks I should just move the paddle to the mouse x position to avoid the lag of using a joint. Thanks! rob