精灵撞到墙壁或另一个精灵
我试图了解当精灵撞到墙上时如何实现精灵的物理原理。 假设我有一堵墙,并且一个精灵正在使用 box2d(cocos2d) 以速度和重力撞击墙壁,应用碰撞旁边发生的物理现象的最简单方法是什么,重新调整速度、重力、角度碰撞等?联系听众?我是否必须自己计算接下来会发生什么并对身体施加新的速度和力量? 或者 box2d 为我做这件事?
任何方向都会很棒。 谢谢。
i am trying to understand how to implement the physics of sprite when it hit a wall.
lets say i have a wall, and a sprite is is hitting the wall with velocity and gravity using box2d(cocos2d), what is the simplest way to apply a physics of what happen next to the hit, regrading the velocity,gravity,angle of collision, etc ? contact listener ? do i have to calculate what happen next by my self and apply a new speed and force to the body ??
or box2d does it for me ?
any direction would be great.
thanx.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
box2d 会为您计算一切。你不必担心两具尸体相撞后会发生什么。
如果您的身体撞到地面,它会按照自然反应反弹。您不必施加与重力相反的新力。所有计算均由box2d物理引擎完成。物理引擎就是为此而设计的。
除此之外,如果您愿意,您可以应用自己的力量或冲动,如下所示。这取决于你。
box2d calculates everthing for you. You don't have to worry about what happens after two bodies collide.
If your body hits ground it will bounce as its natural response. You dont have to apply a new force opposite to the gravity. All calculations are done by box2d physics engine. Physics engines are made for that.
In addition to this, if you want you can apply your own forces or impulses like below. It is up to you.