Author Topic: Suggestion: DEBUG check and some rendering optimization.  (Read 1702 times)

L_O_J

  • Member
  • **
  • Posts: 88
  • Karma: +0/-0
    • View Profile
Here is some little changes that I made just now:
1. I'm pretty sure I've read about this here, but dunno if Flixel had this or not, but it will be nice to add this little function to check if we are running debug build swf or release build (not the player version).
Code: [Select]
public function isDebugBuild():Boolean
{
return new Error().getStackTrace().search(/:[0-9]+]$/m) > -1;
}
Credit to : http://blog.another-d-mention.ro/programming/how-to-identify-at-runtime-if-swf-is-in-debug-or-release-mode-build/

I need this code, so FlxConsole will not show up on Release version SWF or Release Player
Code: [Select]
//@desc This function is only used by the FlxGame class to do important internal management stuff
protected function onKeyUp(event:KeyboardEvent):void
{
if(event.keyCode == 192 && isDebugBuild() && Capabilities.isDebugger)
{
_console.toggle();
return;
}
.
.
.
}

2. I think the rendering process could be more optimized if we consider object is onScreen or not (from FlxLayer).
Code: [Select]
//@desc Automatically goes through and calls render on everything you added, override this loop to do crazy graphical stuffs I guess?
override public function render():void
{
super.render();
var cl:uint = _children.length;
for(var i:uint = 0; i < cl; i++)
if((_children[i] != null) && _children[i].exists && _children[i].visible && _children[i].onScreen()) _children[i].render();
}

3. Well not really related to flixel, but did you guys know that
Code: [Select]
var foo:/*Data Type*/Arrayinstead of
Code: [Select]
var foo:Arrayin FlashDevelop could help the autocompletion (intellisense) in determining (and providing member list) the Type contained in the Array (which is not strongly typed). Just some heads up ;)

Adam Atomic

  • Founder
  • Key Contributor
  • *****
  • Posts: 852
  • Karma: +0/-0
  • new dad
    • View Profile
    • Adam Atomic
FlxG has a debug flag using that method already (that's how the console can show debug or release ;) ), and onScreen() may or may not actually speed up that check, as onScreen() is not free and I have not done any profiling to see if it yields an improvement or not