From the course: Building Flash Games with Starling

Unlock the full course today

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

Creating the three game states

Creating the three game states

From the course: Building Flash Games with Starling

Start my 1-month free trial

Creating the three game states

So now that we have our IState interface created, we can go ahead and create those three Game states: the Menu state, the Play state and the Game Over state. So I'm going to right-click on our source folder and choose New > ActionScript Class, and for a Package we are going to store these state classes in a package called states. And the first one I'm going to create is the Menu state. Now for a superclass this is going to subclass starling.display.Sprite, because it's going to contain the actual visual representation for the state. And for interfaces we are going to Add that IState interface, so if we actually just search for it here we can see the IState interface, click OK, and now we can click Finish. And you could see automatically by implementing that interface it's now created the update and destroy methods for us. So we are going to make a couple of changes to this. The first thing we are going to do is when we create one of these states from our Game class, we are actually…

Contents