Making your first Phaser 3 game hitBomb function not working

Hi, all. Hoping someone can tell me find what I have missed with the hitBomb() in part 10 of the tutorial. I currently have the bomb appear when all stars are collected and a new set of stars appear to start the process again (which adds another bomb). However, the bombs do not collide with the platforms and in my code, when passing in bomb as the second argument I have vscode show me this message.

/* “bomb” is declared but its value is never read */

below is the code of the function

hitBomb(player, bomb) {
this.gameOver = true;

I am confident everything will work if the bomb value is read in the function but i have tried a few different things now and im losing my mind.

I would appreciate any help from you kind folk so that I can carry on with my game dev journey and onto the next phase of my evil plan to create a bigger lootbox scam than EA is running right now!



Open the browser developer tools console and look for errors.

The “value is never read” warning is just because you haven’t used the bomb variable yet.

hey samme, thanks for the quick reply. Apologies, I should have mentioned in my post that there are no errors showing in the console.

I am just not sure where to place the bomb variable in my code so that it will be used by the function. I have placed it outside of the main constructor (as i have with others and those variables work fine) and also tried placing it in several places within the constructor class. Im very confused haha

bomb is the second argument to hitBomb(). If you want to work on that bomb, do something with it inside the function:

function hitBomb(player, bomb) {
  bomb.visible = false;

If you don’t, then remove the argument:

function hitBomb(player) {

ah so i just need to use it inside the function … well that all makes perfect sense now! I knew it would be something silly that i missed haha. Noobs eh!

I really appreciate you taking the time to help samme, thank you for that :+1: