Game Development Reference
In-Depth Information
Monitoring frame rate and memory usage
There are two relatively simple tools we can use to examine the health of a game running in
Flash. The first is to view the current frame rate the system is running under, and the second is
to view changes in the total memory used by the system. Optimizations you have seen
throughout the topic and in this chapter will affect both of these numbers. We will now create a
simple class that you can display on the screen (if you like) to show the current state of these
two important metrics.
The FrameCounter class is used by the FrameRateProfiler to do execute frame rate events for
profiling. A frame rate event is triggered every 1,000 milliseconds (1 second). We also have the
ability to also add a FrameCounter on the screen while the game is running. It displays the profiled
frame rate, the current frame rate, and the current memory used by the system. Figure 11-3
shows it in action.
Let's create this class as the next new file for the Blaster Mines game. It will be part of the game
framework package structure.
Here is the class file name and location:
/source/classes/com/efg/framework/FrameCounter.as
Figure 11-3. The FrameCounter class in action
Search WWH ::




Custom Search