避免在电晕SDK中发生碰撞 [英] avoiding collision in corona sdk
问题描述
如何避免电晕中的物理物体之间发生碰撞?我正在开发的应用程序利用了许多物理物体。我希望在两个所需物体之间发生碰撞,但是系统中所有物体之间都发生碰撞。有人能帮我解决问题吗?
How to avoid collision between physics bodies in corona ? The application that I am developing makes use of many physics bodies.I want collision to happen between two desired bodies,but the collision is happening between all the bodies in the system.Can anyone help me with a solution?
推荐答案
第二种方法是将groupIndex分配给每个对象。该值可以是正整数或负整数,并且是指定冲突规则的更简单方法:具有相同groupIndex值正值的对象将始终相互碰撞,具有相同groupIndex值负值的对象将永远不会相互碰撞。 / p>
There is the second method to assign a groupIndex to each object. The value can be a positive or negative integer, and is a simpler way of specifying collision rules: objects with the same positive groupIndex value will always collide with each other, and objects with the same negative groupIndex value will never collide with each other.
local collisionFilter = { groupIndex = 2 }
physics.addBody(object1, {bounce = .2, density = 1, filter = collisionFilter})
physics.addBody(object2, {bounce = .2, density = 1, filter = collisionFilter})
这篇关于避免在电晕SDK中发生碰撞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!