我正在尝试检测两个物体是否相撞,但我不确定如何做。
我有以下场景,向其中添加了两个物理图像。我只需要一种检测它们相撞的方法。
export class MainGame extends Scene {
public create() {
// Create the player
this.player = this.matter.add.image(300, 100, 'player')
// Create a pillar
let pillar = this.matter.add.image(500, 0, 'pillar1', null, { isStatic: true })
// Somehow detect collision between the two...
}
}
我无法弄清楚如何检测玩家何时与柱子发生碰撞。我搜索到的所有信息都是使用街机物理引擎来完成此操作,但我正在使用物理引擎。
我找不到任何关于如何检测碰撞然后运行函数的信息。