亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Phaser 3 陣列碰撞

Phaser 3 陣列碰撞

慕哥9229398 2023-09-28 09:41:52
在 Phaser 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 spritesthis.physics.add.overlap(bulletA, enemy1, collide1, null, this);碰撞檢測工作正常(我在碰撞時使用 console.log 進行了測試)。但是,我需要能夠判斷敵人 1 數組中的哪個特定敵方精靈正在與我的子彈碰撞。需要發生這種情況,以便我可以對敵人播放爆炸動畫,并將該特定動畫從游戲中刪除。有什么方法可以獲取正在使用重疊的數組的特定元素嗎?
查看完整描述

1 回答

?
慕無忌1623718

TA貢獻1744條經驗 獲得超4個贊

重疊函數接受一個回調,返回兩個碰撞的對象

https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.ArcadePhysics.html#overlap


例如


overlap(bulletA, enemy1, collide1)


function collide1 (ob1, ob2) {

  // ob1 is the bullet that collided with the enemy

  // ob2 is the enemy that collided with the bullet

}


查看完整回答
反對 回復 2023-09-28
  • 1 回答
  • 0 關注
  • 102 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號