Skip to content

Commit

Permalink
altered console behavior when FlxG.mobile is flagged - just traces fr…
Browse files Browse the repository at this point in the history
…ame data instead of displaying whole console
  • Loading branch information
AdamAtomic committed Jun 4, 2010
1 parent a01b8da commit 852e603
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion org/flixel/FlxG.as
Expand Up @@ -27,7 +27,7 @@ package org.flixel
* Assign a minor version to your library.
* Appears after the decimal in the console.
*/
static public var LIBRARY_MINOR_VERSION:uint = 40;
static public var LIBRARY_MINOR_VERSION:uint = 41;

/**
* Internal tracker for game object (so we can pause & unpause)
Expand Down
3 changes: 2 additions & 1 deletion org/flixel/FlxGame.as
Expand Up @@ -412,7 +412,8 @@ package org.flixel

//Initialize game console
_console = new FlxConsole(_gameXOffset,_gameYOffset,_zoom);
addChild(_console);
if(!FlxG.mobile)
addChild(_console);
var vstring:String = FlxG.LIBRARY_NAME+" v"+FlxG.LIBRARY_MAJOR_VERSION+"."+FlxG.LIBRARY_MINOR_VERSION;
if(FlxG.debug)
vstring += " [debug]";
Expand Down
2 changes: 1 addition & 1 deletion org/flixel/FlxText.as
Expand Up @@ -223,7 +223,7 @@ package org.flixel
_pixels = new BitmapData(width,height,true,0);
_bbb = new BitmapData(width,height,true,0);
frameHeight = height;
_tf.height = height*1.2;
_tf.height = height*1.2;
_flashRect.x = 0;
_flashRect.y = 0;
_flashRect.width = width;
Expand Down
32 changes: 24 additions & 8 deletions org/flixel/data/FlxConsole.as
Expand Up @@ -89,9 +89,9 @@ package org.flixel.data
var tmp:Bitmap = new Bitmap(new BitmapData(FlxG.width*Zoom,FlxG.height*Zoom,true,0x7F000000));
addChild(tmp);

mtrUpdate = new FlxMonitor(8);
mtrRender = new FlxMonitor(8);
mtrTotal = new FlxMonitor(8);
mtrUpdate = new FlxMonitor(16);
mtrRender = new FlxMonitor(16);
mtrTotal = new FlxMonitor(16);

_text = new TextField();
_text.width = tmp.width;
Expand Down Expand Up @@ -146,6 +146,8 @@ package org.flixel.data
if(Text == null)
Text = "NULL";
trace(Text);
if(FlxG.mobile)
return;
_lines.push(Text);
if(_lines.length > MAX_CONSOLE_LINES)
{
Expand All @@ -165,6 +167,12 @@ package org.flixel.data
*/
public function toggle():void
{
if(FlxG.mobile)
{
log("FRAME TIMING DATA:\n=========================\n"+printTimingData()+"\n");
return;
}

if(_YT == _by)
_YT = _byt;
else
Expand All @@ -181,11 +189,7 @@ package org.flixel.data
{
var total:Number = mtrTotal.average();
_fpsDisplay.text = uint(1000/total) + " fps";
var up:uint = mtrUpdate.average();
var rn:uint = mtrRender.average();
var fx:uint = up+rn;
var tt:uint = uint(total);
_extraDisplay.text = up + "ms update\n" + rn + "ms render\n" + fx + "ms flixel\n" + (tt-fx) + "ms flash\n" + tt + "ms total";
_extraDisplay.text = printTimingData();

if(_Y < _YT)
_Y += FlxG.height*10*FlxG.elapsed;
Expand All @@ -200,5 +204,17 @@ package org.flixel.data
}
y = Math.floor(_Y);
}

/**
* Returns a string of frame timing data.
*/
protected function printTimingData():String
{
var up:uint = mtrUpdate.average();
var rn:uint = mtrRender.average();
var fx:uint = up+rn;
var tt:uint = mtrTotal.average();
return up + "ms update\n" + rn + "ms render\n" + fx + "ms flixel\n" + (tt-fx) + "ms flash\n" + tt + "ms total";
}
}
}

0 comments on commit 852e603

Please sign in to comment.