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.

Setting up the game state

Setting up the game state

From the course: HTML5 Game Development with Phaser

Start my 1-month free trial

Setting up the game state

We've now come to the point in developing our game where we must begin building out the playable portion of the project. This is our game state. And within this state, we'll create all of the game objects and logic. So inside of our Start menu, when somebody clicks on it, we're going to invoke start game and call this.state.start. And we want to start our games state. So let's create that. We'll create a new file called game.js. And we'll bind that to Bunny Defender. So BunnyDefender.game. And set that equal to a new function, passing in our game object from the index.html file. We now set BunnyDefender.Game.prototype equal to an object which has two specific functions in it for now. One is the phaser create function, and the second is the phaser update function. Again the difference between these two is that the create function runs basically once and this is a good point to set up anything that we need in this state. The update function is something that runs constantly and here we…

Contents