Another one of my attempts to convert a Phaser 2 tutorial to Phaser 3, which other beginners like me might find useful.
This time, I took a look at a fantastic tutorial by Richard Davey from 23 February 2015 titled "Phaser Coding Tips 7 “Creating a Shoot-em-up Tutorial” (here). It’s a short but great tutorial which covers so many of the basic aspects of coding a “bullet-hell” game. First I converted the code to Phaser 3 - the original code structure is basically maintained so one can read the original tutorial together with the converted code.
Then I added 3 different types of enemies that shoot bullets at the player. It’s by no means a complete game but other beginners like me may find something useful in the code, available in Codepen below.
The above code is the “amended” version of the original tutorial code - the “faithful” conversion of the original (without the enemies) is available here.
I have also (pretty much for my own benefit) documented how I added the new functionalities in my blog, here, including comments on things that I probably would do different if I were to code it again.
Question for the “senpai” programmers:
I have used this.physics.add.overlap to detect when enemies are hit by player bullets. When the code is first run and the enemy group and bullet group are created, this seems to trigger the overlap event, unless the below line is included right after createMultiple statement of the bullets group.
this.children.each((bullet) => bullet.disableBody(true,true));
The config for createMultiple sets active to false, but I guess I am not disabling the physics body? Is there a way to disable the body with some property of the createMultiple config?