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.
Now that we have our background, we are going to focus on creating the game over text, and we are going to use a Starling text field to display that. So I'm going to come under where I created my background in my init method. I'm going to create a variable here, and I'm going to call it overText, and I'm going to set that equal to a new text field. And again, be sure you are using starling.text.TextField. And to that, we are going to pass in a few different things; first, the width and the height.
I'm going to put the width at 800, so it's the whole width of my game and we are going to set its align to Center, so that way, it's centered in the middle. And I'm going to set the height here to 200, pass in what actual texturing we want to display, and we can set all of these also outside of the constructor, but I'm just doing it here. We are going to say GAME OVER. Now we need to use uppercase, because remember, when I created that bitmap font, when we did the assets chapter, I only included the glyphs for the uppercase characters because that's all the font actually contains.
Now next is the font name. So remember, in our assets class, we have this Komika font. So if I open that with the Text Editor here, remember this is the name that I need to give when I want to use that font. So I'm going to give it a string of KomikaAxis like that. Now next is the size of the font. I'm going to do 72 and then the color, and I'm going to do white. I'm going to create that as an instance variable.
Now I want to set up a couple of things with it. First, I want to set its align property. So I'm going to set overText and we want to set the hAlign property, and we just set it to a string of center, and now I'm going to set the y position of that. So overText.y, because remember, it will automatically be centered on the x axis. I'm going to set it to 200, and then lastly, we want to add this text to the display list. So addChild(overText); like that.
Let's see what that looks like. So we will launch our game, and we'll die on purpose. And there we have our text nicely centered and we are using that bitmap font. So again, this is a nice way to be able to render text, and we don't have to include a PNG file that says game over. If we are using a lot of text in our game, we can just reference those bitmap fonts, and use the text field class that is included with Starling. So the next step is to add our Try Again button which the user can click on to try again at playing the 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.