Game Development Reference
In-Depth Information
import flash.geom.*;
import flash.events.*;
import flash.utils.getTimer;
import flash.text.*;
import flash.events.EventDispatcher;
/**
* ...
* @author Jeff Fulton
*/
public class FrameRateProfiler extends Sprite {
public static const EVENT_COMPLETE:String = "profile complete";
private var profileTimer:Timer;
//public preperties
public var profilerRenderObjects:int = 500;
public var profilerRenderLoops:int = 10;
public var profilerDisplayOnScreen:Boolean = false;
public var profilerXLocation:int = 0;
public var profilerYLocation:int = 0;
public var profilerFrameRateAverage:int = 0;
private var profilerFrameRate:int = 40;
private var profilerRenderFrames:int = 0;
private var profilerBackground:BitmapData = new BitmapData(400, 400, false, 0x000000);
private var profilerCanvas:BitmapData = new BitmapData(400, 400, false, 0x000000);
private var profilerBitmap:Bitmap = new Bitmap(profilerCanvas);
private var profilerObject:BitmapData = new BitmapData(20, 20,false, 0xff0000);
private var profilerFrameRateTotal:int=0;
private var profilerFrameRateEventCounter:int = 0;
private var profilerFrameCount:int = 0;
private var profilerTempObject:Object;
private var profilerObjectArray:Array = [];
private var profilerRenderPoint:Point = new Point(0, 0);
private var profilerFrameRateArray:Array= [];
private var format:TextFormat=new TextFormat();
private var messageTextField:TextField = new TextField();
private var frameCounter:FrameCounter = new FrameCounter(); //added chapter 11
public function FrameRateProfiler() {
addChild(frameCounter);
frameCounter.x = 0;
frameCounter.y = 0;
}
public function startProfile(frameRate:int):void {
trace("start profile");
profilerFrameRate = frameRate;
Search WWH ::




Custom Search