开发者

How do I give a Box2d Kinematic body a predefined curved path

开发者 https://www.devze.com 2023-04-12 00:35 出处:网络
I\'m new to using Box2d and really can\'t find a consistent answer to my question so please excuse me.

I'm new to using Box2d and really can't find a consistent answer to my question so please excuse me.

I'm writing a game for the 开发者_如何学编程iPhone -- who isn't these days -- and I'm using Cocos2d and Box2D. I have objects that move around in the game and I would like to give them a more of a curved path. From my studies I know that I should use body of type b2_kinematicBody which allows me to change the linear velocity every tick and keeps them from colliding with my other flying bodies. I do understand that if I know my current position (x,y) and my next position in the step (x1,y1) I would be able to compute the vector for velocity. Does anybody have a good way to give an object a defined curved path? I'm thinking it has to be some kind of parametric equation.


Take a look at bezier curves. After curve defenition you can compute the derivative (it's easy for bezier) and use it as a velocity for your body


OH whats the game called? sounds like a good one. have you looked into maybe just doing that in version 2.0

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号