Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
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, we have our animating background in our game over text. Last thing we need to do in the GameOver state is to create our Try Again button. So I am going to create a property here called tryAgain. I'm going to set that equal to a new Starling button instance, and now we need to get that texture from our texture atlas. So I am going to say Assets, make sure we import that class .ta.getTexture and the texture name is tryAgainButton.
Now let's go ahead, and create that as an instance variable. Now we want to set the pivot X property of the button. That way we can easily position it in the center of our movie. So we are going to say tryAgain.pivotX = tryAgain.width * 0.5. Let's position this now. So we are going to say tryAgain.x. You can put it right in the center at 400, tryAgain.y = 450.
Again, that's just a trial and error thing to position it correctly. Now let's add it to the display list; so addChild (tryAgain). Now much like we did in the menu state, we need to listen for the triggered event on this button so that we know when to actually let the user play the game again. So I am going to come right under where we created it and say, tryAgain.addEventListener. We want Event. Again, make sure you get starling. events.Event, and now we want the TRIGGERED event, and we'll just call the event handler onAgain.
So let me create that method, and make sure we have our event object being caught here. And in this onAgain event, what we are going to do is to change the game state to play. So again, we're going to say game.changeState, and then we are going to get that static state property of PLAY_STATE. So now let's go ahead and test it, and make sure it works. So we'll debug here, click Play Game, and I'll let myself die.
We are in the GameOver state, and we can see our button being displayed, and when I click it, we actually go back to the Play state. Okay, so now we just need to implement the destroy method here, and to do that, we are essentially just going to removeFromParent(true). So we are going to make sure we dispose that. Now one of the things that's good practice to do is since we are listening for this event here, let's go ahead and unregister for that event here.
We'll say tryAgain.removeEventListener. So again, my philosophy on cleaning up after yourself, it's better to do more. Even if some things aren't entirely necessary, it's just good practice to get into. So now let's go ahead and test it. Again, we come in, we have our game, we die, GameOver state; TRY AGAIN brings us back to the play state so we continue playing our game. And again, I just wanted to highlight to you that the performance that you are seeing here is not necessarily accurate of the real performance of the game.
For numerous reasons, this is a debug build, and I mentioned before how with Starling in particular, you really need to do a release build of your game in order to get an idea of the real performance, because you can see even though the frame rate here is 60 frames per second, it still looks a little stuttery, and that's because we are looking at this using a debug build and also in the debug player. But that's the GameOver state, and in the next chapter, we are actually going to focus on creating some more visual effects.
We are going to create particles so that when you actually shoot a bullet and it hits an alien, we are going to see an explosion particle so we'll add a little more eye candy to our game in the next chapter.
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.