Thanks everyone for replying..
I have moved my mouseJoint creation code in my init function (only once) and it seems to be working but now I am having trouble determining exactly what to pass to SetTarget.
I am using CoCos2d as game framework
I am trying to move an object (X) using mouseJoint towards object (Y)
Y is defined as a b2Body.
_mouseJoint is set up for Object X
//position of where I want my object to move to
b2Vec2 b2Position = b2Vec2(Y->GetPosition().x *PTM_RATIO,Y->GetPosition().y*PTM_RATIO));
//move object to desired position
_mouseJoint->SetTarget(b2Position);
On launch, the object moves towards one end of the screen and not towards Y. So I tried
_mouseJoint->SetTarget(0,0)
What I expected to happen is that X would move towards the lower corner (0,0) of the screen. Instead, it didn't move at all.
It seems like setTarget is taking in a "force" instead of a location.
What exactly am I supposed to pass ?
I have moved my mouseJoint creation code in my init function (only once) and it seems to be working but now I am having trouble determining exactly what to pass to SetTarget.
I am using CoCos2d as game framework
I am trying to move an object (X) using mouseJoint towards object (Y)
Y is defined as a b2Body.
_mouseJoint is set up for Object X
//position of where I want my object to move to
b2Vec2 b2Position = b2Vec2(Y->GetPosition().x *PTM_RATIO,Y->GetPosition().y*PTM_RATIO));
//move object to desired position
_mouseJoint->SetTarget(b2Position);
On launch, the object moves towards one end of the screen and not towards Y. So I tried
_mouseJoint->SetTarget(0,0)
What I expected to happen is that X would move towards the lower corner (0,0) of the screen. Instead, it didn't move at all.
It seems like setTarget is taking in a "force" instead of a location.
What exactly am I supposed to pass ?