Viewers: in countries Watching now:
Join Lee Brimelow in this project-style course that teaches how to build a Flash-based game with Flash Builder 4.6, Flash Player 11, and the Starling framework. Starling, a pure ActionScript 3.0 library for advanced graphics, extends Flash Player 11's support for the modern GPU (graphic processing unit) to enable visual presentations and games in the browser or as a mobile app.
Starting with installation and configuration of Starling and creation of a Flash Builder project, the course shows how to prepare and import graphical assets, create MovieClip classes from sprite sheets, manage various gaming objects, detect collisions, and add both particle and sound effects. The finished game can be deployed to any browser or mobile device that integrates Flash Player 11, which was released in September 2011.
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 going to send in a reference to our main Game class so that we can communicate back to it.
So in the constructor here, I'm going to put an argument called game, and this is going to be of type Game. And now inside of our constructor we are going to create an instance property called game, so I'm going to say this.game = game; and now I can hit Command+1 or Ctrl+1 to get a quick fix to create that as an instance variable at the top. So now anywhere inside of this state I can actually call back to our main Game class. Now the next thing I'm going to do is to add an event listener for the added to stage event, again because we don't want to do anything here until we know it's been added to the stage.
So I'm going say addEventListener and again be sure when you are importing event that you are importing starling.events.Event. We are going to listen for ADDED_TO_ STAGE and we are going to have it call a function called init. And let's go ahead and define that function now. So private function init, we are going to have our event object be of type starling.events.Event. I'm not going to return anything and now we have that set up. So this is going to be main template that each of our states is going to implement.
So what I'm going to do is copy this entire class to the clipboard, and now I'm going to right-click in the states package and we are going to create the other two states. So New > ActionScript Class, and this one is going to be called Play, and again, the Superclass is going to be starling.display.Sprite. For interfaces we are going to implement that IState interface and click Finish. Now I'm just simply going to select all of text in here and paste in that Menu state, because now all we need to do is to simply change Menu to Play here and there, and now we have our Play state created.
So now we are going to do the same thing for the Game Over state. So New > ActionScript Class, this one is called GameOver, Superclass is going to be Sprite. We are going to implement the IState interface, click Finish, and again, replace the text with the text that's on the clipboard, change this to GameOver and GameOver like that. So now you can see we have our states package and we have our three states created.
So now in the next movie we are going to look at implementing a state machine which is going to control the switching of the various states of our game.
There are currently no FAQs about Building Flash Games with Starling.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.