From the course: HTML5 Game Development with Phaser

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Spawning enemies

Spawning enemies

From the course: HTML5 Game Development with Phaser

Start my 1-month free trial

Spawning enemies

- Our game will also have a number of obstacles which we must defend our bunnies against. These obstacles take the form of space rocks, with various attributes attributed to them such as speed and size. We'll use the same phaser grouping mechanism to manage these entities which were used for the bunnies. The first thing we'll need to do is actually load in the sprite sheets for our space rocks, just as we did for the bunnies. Popping over to preloader dot j s. Immediately after we load in the atlas xml for the bunny, we'll do the same thing for our space rocks sprite sheets. So this dot load dot atlas xml and here we'll give it the identifier of space rock. We'll pass in a reference to the image file, so images, sprite sheets, space rock dot ping, and the data file, so images, sprite sheets space rock dot xml. Now that that's loaded up we can go back to our game state, and here we want to add some variables underneath those that are attributed to our bunnies. So we'll add this dot…

Contents