如何为 Box2d 运动体提供预定义的弯曲路径
我是 Box2d 的新手,确实找不到我的问题的一致答案,所以请原谅。
我正在为 iPhone 编写一款游戏——现在已经不是这样了——我正在使用 Cocos2d 和 Box2D。我有一些在游戏中移动的物体,我想给它们一个更多的弯曲路径。根据我的研究,我知道我应该使用 b2_kinematicBody 类型的主体,它允许我改变每个刻度的线速度,并防止它们与我的其他飞行主体碰撞。我确实明白,如果我知道我当前的位置 (x,y) 和步骤 (x1,y1) 中的下一个位置,我将能够计算速度向量。有没有人有一个好方法来给一个物体一个定义的弯曲路径?我认为它必须是某种参数方程。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看一下贝塞尔曲线。曲线定义后,您可以计算导数(对于贝塞尔曲线来说很容易)并将其用作您身体的速度
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
哦,这个游戏叫什么名字?听起来不错。你有没有考虑过在 2.0 版本中这样做
OH whats the game called? sounds like a good one. have you looked into maybe just doing that in version 2.0