Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

7. Creating Game Screens and HUDs > Player Stats Screen

Player Stats Screen

Next up, we are going to look at how we can keep track of player stats such as the time it took to complete a level, total number of kills, and how many times the player died. Instead of making this screen a separate game class, we are going to build it into our MyGame class.

We are going to need to add impact.timer to the requires block of our MyGame class. Add the following properties to the MyGame class:

statText: new ig.Font( 'media/04b03.font.png' ),
showStats: false,
statMatte: new ig.Image('media/stat-matte.png'),
levelTimer: new ig.Timer(),
levelExit: null,
stats: {time: 0, kills: 0, deaths: 0},

The following properties will allow us to track the visibility of the stats display, an image we can use to mask the screen, a font, a timer, and a stats object. Next, we are going to need to override the loadLevel() method so we can start a timer to track how long it takes the player to complete the level:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial