Search code examples
haxeflambe

How to use the trace method in Flambe?


I am trying to use the trace method to print a string on the screen. I thought that Haxe code should work in Flambe, but apparently it doesn't. I tried to run this code but all I get is a black screen:

package urgame;

class Main {
  static public function main():Void {
    trace("Hello World");
  }
}

I took the code from this haxe guide.

I also tried to use this code but the result is identical (black screen):

package urgame;

import flambe.Entity;
import flambe.System;
import flambe.asset.AssetPack;
import flambe.asset.Manifest;
import flambe.display.FillSprite;
import flambe.display.ImageSprite;
import flambe.display.Sprite;

class Main
{
    private static function main ()
    {
        // Wind up all platform-specific stuff
        System.init();

        // Load up the compiled pack in the assets directory named "bootstrap"
        var manifest = Manifest.fromAssets("bootstrap");
        var loader = System.loadAssetPack(manifest);
        loader.get(onSuccess);
    }

    private static function onSuccess (pack :AssetPack)
    {
        trace('Hello World');
    }

Solution

  • If you run the html version the traces should be displayed in the browser console. So do build and run (debug build) and hit F12 in the browser.