Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Creating a results screen

From: Flash Professional CS5: Creating a Simple Game for Android Devices

Video: Creating a results screen

Creating game play is one thing, but just as important is removing this game play and showing the end screen. So let's start off and I'm just going to go ahead die immediately. Wait for those guys to reach the bottom. All right, so this is the Results screen. As you can tell, there are some UFOs that just are frozen in time are right here on the screen, and not only that, my spaceship is actually moving around, and it's still generating these lasers even though they're not moving.

Creating a results screen

Creating game play is one thing, but just as important is removing this game play and showing the end screen. So let's start off and I'm just going to go ahead die immediately. Wait for those guys to reach the bottom. All right, so this is the Results screen. As you can tell, there are some UFOs that just are frozen in time are right here on the screen, and not only that, my spaceship is actually moving around, and it's still generating these lasers even though they're not moving.

So just as important as creating this gameplay, I need to actually remove all of these elements. And most of these elements are actually dynamically created, so I need to go through and dynamically remove all of those items. And I am going to do this by looping through these arrays, so I need to remove the explosions, the enemies, and the lasers. So in the Mobile Game folder in our Code Snippets panel right down here, Loop through Items in an Array. That's what I want to add.

It adds this code right here. All right, so I'll just hit Return to bring that up. So it loops through an enemies array, and it will do something to each one of those items. Well, I actually want this to happen when the game is over with. So I am going to go ahead and move this code. I am going to move it into the removeGame function. So I am going to cut it. I am going to scroll up right here at line 325, here is my removeGame function, and I am going to paste it right in there.

And I'll just click that Format button, so everything indents appropriately. And now it says for the enemies array, loop through it and then do something for each item. Now if you do recall what we're doing for each one of these items is we already have these removeEnemy functions, removeLasers, and removeExplosion functions. So I want to use these same functions for removing all of those elements. So I'm just going to go ahead and copy this function name or removeEnemy. I am going to come down in here and paste it right over that comment.

And I am going to go ahead and call that function, and I am going to pass the variable i into it. So I'll copy that and paste that right in there. So it will loop through the entire length of the array, everything in that array, and it will remove all of those enemies. All right, I need to do the same thing for the lasers, so next step is going to be Remove lasers. Take all of this for loop, paste it below. And for this array it is actually called Lasers. Not only that, I don't want to establish another variable with the same name. I actually need to change that variable name. I'll just change it to j. So wherever I see i I'll just change to j, just like that. And removeEnemy, well, no I don't want to remove the enemy; I just want to remove the Laser and type j right in there.

All right, so far so good. I'll copy this for loop again, because again I need to do the same thing for the Explosions. Paste that in. And again, for the explosions, I'll just type in k for the variable. The array, again, is going to be explosions. K for that variable name, just like that, removeExplosion, just like that, type in k, and there we are.

So that will loop through all those arrays and remove all of those elements. That's great. That's exactly what I want. I just need to do a couple more things in here. I need to go ahead and remove the player, and that's as simple as typing in removeChild(player). There is only one. I can call it directly by its name. And then to stop that laser timer, I'll just type in laserTimer. Again, that's what actually makes all of those various lasers, and all I need to do is stop it, just like that.

All right, I'd say that it looks pretty darn good. Again, this is in the removeGame function. And again, when that endGame gets called, it's going to remove basically all the game elements like its shown in here, and then of course it shows the endScreen and does some other things. So let's go ahead and run this: Control > Test Movie. And I am going to quickly die in here, so you can see the results screen.

There we are, a nice clean results screen. I don't have any of the UFOs frozen or any lasers frozen or explosions, and I'm not controlling the player anymore because the player doesn't exist. That looks great. I have ended the game correctly. Now, really the next step is to start to add some various scoring on this final screen.

Show transcript

This video is part of

Expand all | Collapse all
  1. 1m 48s
    1. Welcome
      1m 0s
    2. Using the exercise files
      48s
  2. 7m 16s
    1. Understanding the user
      4m 2s
    2. Flash content on Android devices
      3m 14s
  3. 17m 28s
    1. Reviewing the game
      1m 50s
    2. Creating a file in Device Central
      5m 39s
    3. Reviewing the game structure
      8m 23s
    4. Adding code snippets
      1m 36s
  4. 36m 13s
    1. Animating the intro screen
      8m 13s
    2. Moving the player
      8m 13s
    3. Adding enemies
      6m 49s
    4. Adding movement
      4m 16s
    5. Adding chance and randomness
      8m 42s
  5. 34m 30s
    1. Adding lasers
      8m 14s
    2. Detecting collisions
      7m 57s
    3. Adding explosions
      6m 26s
    4. Removing assets from the stage
      8m 50s
    5. Adding audio
      3m 3s
  6. 33m 12s
    1. Adding scoring and levels
      7m 41s
    2. Subtracting lives and ending the game
      4m 26s
    3. Creating a results screen
      5m 8s
    4. Displaying the score
      6m 57s
    5. Saving and loading game results
      9m 0s
  7. 17m 14s
    1. Detecting movement with the Accelerometer
      6m 39s
    2. Using the swipe gesture
      4m 42s
    3. Using hardware keys
      5m 53s
  8. 23m 18s
    1. Handling exits and idle mode
      3m 31s
    2. Handling activation and deactivation
      6m 14s
    3. Optimizing graphics
      7m 14s
    4. Optimizing ActionScript
      6m 19s
  9. 34m 41s
    1. Creating the application files
      8m 23s
    2. Creating the app (Mac)
      5m 5s
    3. Creating the app (PC)
      7m 19s
    4. Publishing to an Android device (Mac)
      7m 7s
    5. Publishing to an Android device (PC)
      6m 47s
  10. 8m 56s
    1. Uploading to the Android market
      7m 7s
    2. Downloading from the Android market
      1m 49s
  11. 1m 22s
    1. Next steps
      1m 22s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Flash Professional CS5: Creating a Simple Game for Android Devices.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.