Newbie here
I am developing a game in Single Player mode and I need to simulate Computer Movement [FYI: I am using CoCos2d]
I have been trying to move an object using its mouse Joint.
//code Sample (I am testing to see if I can move the "computer" object along the same X axis as my "ball", Y position stays the same)
b2Vec2 b2Position = b2Vec2(ball.position.x/PTM_RATIO,computer.position.y/PTM_RATIO);
b2MouseJointDef md1;
md1.bodyA = _groundBody;
md1.bodyB = computerb2Body;
md1.target = b2Position;
md1.collideConnected = true;
md1.maxForce = 1000.0 * computerb2Body->GetMass();
_mouseJoint = (b2MouseJoint *)_world->CreateJoint(&md1);
computerb2Body->SetAwake(true);
_world->DestroyJoint(_mouseJoint);
_mouseJoint = NULL;
I do all of this in my Tick Method....
When I used the SetTransform (Cocos2d) method on the same b2Position Vector, it works. When I switched to the MouseJoint method, nothing happens. The same mouseJoint code is used else where to process TouchEvents and it works. But using it in my tick() doesn't do anything.
What am I doing wrong here 🙁 ?
I am developing a game in Single Player mode and I need to simulate Computer Movement [FYI: I am using CoCos2d]
I have been trying to move an object using its mouse Joint.
//code Sample (I am testing to see if I can move the "computer" object along the same X axis as my "ball", Y position stays the same)
b2Vec2 b2Position = b2Vec2(ball.position.x/PTM_RATIO,computer.position.y/PTM_RATIO);
b2MouseJointDef md1;
md1.bodyA = _groundBody;
md1.bodyB = computerb2Body;
md1.target = b2Position;
md1.collideConnected = true;
md1.maxForce = 1000.0 * computerb2Body->GetMass();
_mouseJoint = (b2MouseJoint *)_world->CreateJoint(&md1);
computerb2Body->SetAwake(true);
_world->DestroyJoint(_mouseJoint);
_mouseJoint = NULL;
I do all of this in my Tick Method....
When I used the SetTransform (Cocos2d) method on the same b2Position Vector, it works. When I switched to the MouseJoint method, nothing happens. The same mouseJoint code is used else where to process TouchEvents and it works. But using it in my tick() doesn't do anything.
What am I doing wrong here 🙁 ?