Game Development Reference
In-Depth Information
The pause functionality requires that the paused variable of the GameFrameWork class be passed
into the Game class instance. Let's take a look at what is necessary to add in functionality for the
time-based step timer and see how this functions.
Implementing the time-based step timer for Blaster Mines
We need to override the systemGamePlay function to pass both the paused and the
timeDifference variables into the Game class:
override public function systemGamePlay():void {
game.runGameTimeBased(paused,timeDifference);
}
As we have discussed previously, the Game base class will be modified to add a function called
runGameTimeBased . This function will act on these two variables.
Also, the startTimer function call has been moved to a new function called
frameRateProfileComplete . Let's start our discussion of implementing the FrameRateProfiler next.
Customizing FrameRateProfiler for Blaster Mines
We need to add some new code in the init function to customize the FrameRateProfiler for the
current game. These alterations are somewhat subjective and will change based on the game
you are creating and the system you are creating them on. First, we'll look at the lines of code,
and then we will examine the theory behind their use:
frameRate = 40;
frameRateProfiler = new FrameRateProfiler();
frameRateProfiler.profilerRenderObjects = 4000;
frameRateProfiler.profilerRenderLoops = 7;
frameRateProfiler.profilerDisplayOnScreen= true;
frameRateProfiler.profilerXLocation = 0;
frameRateProfiler.profilerYLocation = 0;
First, we set the desired frameRate value for our game. This should match or be below the frame
rate setting you have place in the publish options for your SWF. The profileRenderObjects value
is the most important setting we have for the FrameRateProfiler . We will need to experiment with
this number just a small amount to see how it affects the render profile. The reason for this
experimentation is that each machine and plug-in version combination will end up with a different
FrameRateProfiler result. For this reason, you will need to base the number of objects to profile
on your own machine or machines available to you. You will need to calibrate the profiler for your
own development environment.
How do we calibrate the profileRenderObjects value? For example, if we want the game to play
to at 40 FPS, we will need to set the number of objects in the profile to an arbitrary number (let's
say 4,000) and then run the profile and the game. If the profiled frame rate comes out to be 35,
but when we play the game our machine keeps the frame rate at 40, we will need to use less
objects in my profile. This indicated that the number of objects in the profile was too high. We
overtaxed the profiler in a way that was not representative of our gameplay. You might want to
play the game multiple times and note to frame rate during play. The goal is to have the profiled
rate and the rate the game runs on your machine match. This calibration is necessary to ensure
that the number of objects in the profile is a good indication of how the various users' machines
will play your game.
Search WWH ::




Custom Search