Glitch in "Making your first Phaser Game" tutorial

In part 10 of the “Making your first Phaser Game” tutorial (http://phaser.io/tutorials/making-your-first-phaser-3-game/part10) there’s a problem with generating the bombs.

As-written, the bombs generated after you collect a star will only be shown if there are no more stars to collect; it’s inside the "if (stars.countActive(true) === 0) " conditional block.

Based on the text of the tutorial it seems that the intent is for a bomb to be created after each star is collected.

If the following code is moved outside that block, but still inside the collectStar function, it appears to behave as intended:

    var x = (player.x < 400) ? Phaser.Math.Between(400, 800) : Phaser.Math.Between(0, 400);
    var bomb = bombs.create(x, 16, 'bomb');
    bomb.setBounce(1);
    bomb.setCollideWorldBounds(true);
    bomb.setVelocity(Phaser.Math.Between(-200, 200), 20);

I didn’t see anything similar already listed here, but didn’t see this listed anywhere. If I missed it, my apologies.

1 Like