Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

How can I make a b2Body move in a arc-like or curved path? I have heard about cocos2d Bezier curve function (ccBezier) but this is for moving cocos2d sprites. Or can it be modified to move box2d bodies? Any help is appreciated. Thank you.

share|improve this question
    
Why not just model a parabola and apply the necessary force? You get such an effect coming out of a cannon (arc). –  Vaughan Hilts Aug 29 '12 at 19:59
    
@VaughanHilts: I am not sure how to model a parabola –  colilo Aug 29 '12 at 23:10
    
Give your world a somewhat realistic gravity force. Then just apply an impulse at some angle. Box2D models real world physics and you're projectile will travel in a parabola just like real life. –  Amplify91 Sep 14 '12 at 18:29

1 Answer 1

For box2d with gravity enabled, if you apply force to an object in the upwards direction, you will automatically get a parabolic trajectory.

Create a b2vec2 and apply that as the force to your body.

If you want to move the body or sprite manually, then use parabolic formulas to calculate your position in your update method.

share|improve this answer
    
Good answer, but it is highly NOT recommended to move the body manually. Just thought it was worth mentioning :) –  Amplify91 Sep 14 '12 at 18:30
    
Thanks, yes I agree. Tried it once and updates were jittery. –  magdalina Sep 14 '12 at 19:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.