Skip to content

Debugging

markknol edited this page Sep 9, 2014 · 14 revisions
### 💻 Writing messages to the console Haxe provides developers with a powerful trace system. You can simply call trace everywhere within your own functions: ``` trace("Hello world !"); ``` In FlashDevelop on a flash target, you can read the messages in the _output-window_ and in Javascript it will be written in the browsers console. Each trace is displayed with Filename and Line number informations where the trace occured : > `Test.hx:11: Hello world !`

⚠️ Debug messages only appear in a debug build.
Trace is a Haxe build-in function. More info: http://haxe.org/doc/cross/trace

🔴 Breakpoints

In FlashDevelop you can add breakpoints by clicking on the left side of a linenumber in the editor and choose 'test project' (blue play-button in top bar). Note that to debug from within FlashDevelop, your browser needs the Flash debug player.

Conditional compilation

For debug purposes it could be very useful to use debug conditional compilation tags.

Display the current framerate

To check if your game still runs in 60 fps, you can use the FpsDisplay, which displays the current framerate. You need a font to display it.

   var font:Font = new Font(pack, "myFont"); 
   var fpsMeterEntity = new Entity().add(new TextSprite(font)).add(new FpsDisplay());
   System.root.addChild(fpsMeterEntity);

Seeing logs/errors in mobile browser

Clone this wiki locally