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
From the course: HTML5 Game Development with Phaser
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.