Game Development Reference
In-Depth Information
These are the private variables:
private var profilerFrameRate:int = 40;
: The desired frame rate for the game
private var profilerRenderFrames:int = 0;
: The number of frames to run the profiler,
calculated based on the passed in
profilerRenderLoops
value
private var profilerBackground:BitmapData = new BitmapData(400, 400, false,
0x000000);
: Background for the profiling screen
private var profilerCanvas:BitmapData = new BitmapData(400, 400, false,
0x000000);
: The
BitmapData
canvas to display objects for profiling
private var profilerBitmap:Bitmap = new Bitmap(profilerCanvas);
: Display object
to show profiling
private var profilerObject:BitmapData = new BitmapData(20, 20,false,
0xff0000);
: The look (a square) for the profiled objects
private var profilerFrameRateTotal:int=0;
: The total of all frame rates collected in
the profile session
private var profilerFrameRateEventCounter:int = 0;
: The number of profile events
(An event is triggered each second.)
private var profilerFrameCount:int = 0;
: The total frames the profiler has run
private var profilerTempObject:Object;
: A temporary render object for the profiler
render phase
private var profilerObjectArray:Array = [];
: An array of render profile objects
private var profilerRenderPoint:Point = new Point(0, 0);
: The shared point used
to blit render objects to the screen
private var profilerFrameRateArray:Array = [];
: An array of frame rates calculated
1 per second
private var format:TextFormat = new TextFormat();
: The format for displayed text
private var messageTextField:TextField = new TextField();
: The text field for the
render percentage text display
private var frameCounter:FrameCounter = new FrameCounter();
: A
FrameCounter
instance (a new custom class)
These are the public functions:
public function FrameRateProfiler()
: The constructor takes in no parameters. It adds
an instance of the
FrameCounter
class that we will create in the next section. It also
positions it on the screen.
addChild(frameCounter);
frameCounter.x = 0;
frameCounter.y = 0;