Corona sdk物理两个圆形物体之间的精确碰撞
我正在准备一场高尔夫球比赛的开始,球滚入洞中。我让它工作了,但是当球只是接触到洞的边缘时,碰撞事件就会使它掉进去(消失)。我想创造更精确的效果,使其更加真实。任何建议将不胜感激。
I am working on the start of a golf game where a ball rolls into a hole. I have it working, but when the ball simply touches the edge of the hole, the collision event makes it drop in (disappear). I want to create more precision so that it will be more realistic. Any advice would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决这个问题最简单的方法是让真实的物体成为一个比用户看到的显示球更小的隐形球。您还可以操作碰撞前和碰撞后事件处理程序来处理此问题。
您还应该警惕速度在 Box2d 碰撞中很重要这一事实。根据我的经验,这种机制经常需要一些调整。
http://developer.anscamobile.com/content/game-edition-collision-detection
The easiest way to solve this problem is have the real body be an invisible ball smaller than display ball that the user sees. You can also manipulate the pre and post collision event handlers to deal with this.
You also should be wary of the fact that speed matters in Box2d collisions. This kind of mechanic often takes some tweaking in my experience.
http://developer.anscamobile.com/content/game-edition-collision-detection
当您检测到与孔的碰撞时,您可以启动过渡。这种转变需要一些时间才能完成,从而消除“球立即消失”的问题,并且通过一些数学运算,可以正确反映球的速度和方向,以便球落入洞中看起来相当真实。
You could start a transition when you detect the collision with the hole. That transition would take some time to complete, eliminating your "ball immediately disappears" problem, and with a little math, could properly reflect the speed and direction of the ball so that the drop into the hole looks fairly realistic.