我有 4 个身体:2 个球和 2 个平台。
我希望球能够重叠(没有碰撞),但仍然与两个平台发生碰撞。我已经阅读了官方的Matter.js 文档并使用了collisionFilter
演示,但仍然无法掌握实现我需要的东西。
let defaultCollision = 0x0001;
let ballCollision = 0x0002;
let holderCollision = 0x0004;
let floorCollision = 0x0008;
ball1 = Bodies.circle(...
collisionFiler: { mask: ballCollision }
...
});
ball2 = Bodies.circle(...
collisionFiler: { mask: ballCollision }
...
});
// ^ these balls don't collide, which is good.
platform1 = Bodies.circle(...
collisionFiler: { mask: holderCollision }
...
});
platform2 = Bodies.circle(...
collisionFiler: { mask: floorCollision }
...
});
// I don't understand why the balls pass right through these platforms...
任何帮助将不胜感激。