Load and Display the Required Assets

Introduction

Now that we’ve created a basic skeleton of our game using Phaser, let's implement the logic for our game. As a first step, we will be loading all the required assets for our game. Since this is going to be a one-time operation, it can be written inside the preload() function of the scene object that we created earlier.

Now let's implement this functionality.

Load the required assets for the game

Here, we'll write the logic to load the images. Now, if you remember, we added the three functions in a scene object that was later used by the Phaser.Game class to create a Game object. Below is the structure of the scene object for your reference:

Get hands-on with 1200+ tech skills courses.