本文介绍了JavaScript,Matter.js:禁用一个主体的冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 正如标题中已经提到的,我正在寻找一种方法来禁用Matter.js中身体的每次碰撞。它仍然可以与Constraints链接,并且应该有可能在一段时间后再次启用碰撞。有没有办法做到这一点?关于它的难点在于,对象不应该与任何其他对象发生碰撞,但所有其他对象应该相互碰撞。As already mentioned in the title, I am looking for a way, to disable every collision of a body in Matter.js. It should still be linkable with Constraints, and there should be the possibility of enabling the collision again after some time. Is there a way to do this? The hard thing about it, is that the object should not collide with any other object, but all the other objects should collide with each other.推荐答案您可以使用碰撞过滤器来做这个。您可以在碰撞过滤演示中找到它们的示例,并且源代码。You can use collision filters to do this. You can see an example of them working in the collision filtering demo and the source code.他们的工作方式类似于他们在Box2d中所做的工作,其中有一个很好的文章您可以用它来了解它们的工作原理。They work similarly to how they do in Box2d, for which there is a good article you can use to get an idea of how they work. 这篇关于JavaScript,Matter.js:禁用一个主体的冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-14 11:42