I'm new to BOX2d and I need to move the body and the sprite from the center to the point where there was contact with a low rate, I tried to use a projectile-> SetTransform (b2Vec2 (location.x / PTM_RATIO, location.y / PTM_RATIO), 0);
but the movement is very fast and no noticeable
Asked
Active
Viewed 1,839 times
1
2 Answers
0
i dont know much about this but try ApplyForce or ApplyImpulse property

Virat Naithani
- 783
- 12
- 31
-
Applying ApplyLinearImpulse body moves, but deviates from the point to which should move with repeated touches does not behave properly – Invader Jul 01 '11 at 13:54
-
then try mouse joint try this tutorial -> http://www.raywenderlich.com/475/how-to-create-a-simple-breakout-game-with-box2d-and-cocos2d-tutorial-part-12 – Virat Naithani Jul 02 '11 at 05:03
-
Thank you all, but after experimenting with mouseJoint I came to the conclusion that it is better to play with impulse and velocity, got what I wanted! – Invader Jul 06 '11 at 07:15
0
Try using a mouse joint. From the Box2d manual:
[A mouse joint] attempts to drive a point on a body towards the current position of the cursor. There is no restriction on rotation.
Searching for mouse joint will give you quite a few samples...
http://www.box2d.org/forum/viewtopic.php?f=8&t=402
http://iphonedev.net/2009/08/05/how-to-grab-a-sprite-with-cocos2d-and-box2d/

Michael Fredrickson
- 36,839
- 5
- 92
- 109