【发布时间】:2020-12-01 19:18:58
【问题描述】:
在移相器 3 中,我使用重叠来检查碰撞。我的代码如下:
//bulletA is an array(one of the 2 arrays where collison is being checked) it contains all my bullet sprites
//enemy1 is an array containing all the enemies, which I am testing for collision with my bullets. It contains all my enemy sprites
this.physics.add.overlap(bulletA, enemy1, collide1, null, this);
碰撞检测工作正常(我在碰撞时使用 console.log 进行了测试)。但是,我需要能够分辨出enemy1 数组中的哪个特定敌人精灵与我的子弹相撞。这需要发生,以便我可以在敌人身上播放爆炸动画,然后从游戏中删除那个特定的动画。有什么方法可以获取使用重叠的数组的特定元素吗?
【问题讨论】:
-
ArcadePhysicsCallback 返回发生碰撞的对象。 photonstorm.github.io/phaser3-docs/…
标签: javascript phaser-framework