haxehaxeflixelhaxeui

Can I use HaxeUI with HaxeFlixel?


I tried to use both HaxeUI and HaxeFlixel, but what I obtain is HaxeUI's interface over a white background, covering everything underneath. Moreover, even if it was possible to somewhat make HaxeUI and HaxeFlixel work together, it's not clear how to change the UI of HaxeUI when the state change in HaxeFlixel. Here is the code I used:

private function setupGame():Void {

    Toolkit.theme = new GradientTheme();
    Toolkit.init();

    var stageWidth:Int = Lib.current.stage.stageWidth;
    var stageHeight:Int = Lib.current.stage.stageHeight;

    if (zoom == -1) {
        var ratioX:Float = stageWidth / gameWidth;
        var ratioY:Float = stageHeight / gameHeight;
        zoom = Math.min(ratioX, ratioY);
        gameWidth = Math.ceil(stageWidth / zoom);
        gameHeight = Math.ceil(stageHeight / zoom);
    }

    trace('stage: ${stageWidth}x${stageHeight}, game: ${gameWidth}x${gameHeight}, zoom=$zoom');
    addChild(new FlxGame(gameWidth, gameHeight, initialState, zoom, framerate, framerate, skipSplash, startFullscreen));

    Toolkit.openFullscreen(function(root:Root) {
        var view:IDisplayObject = Toolkit.processXmlResource("assets/xml/haxeui-resource.xml");
        root.addChild(view);
    });
}

I can guess that, probably, both HaxeUI and HaxeFlixel have their own main loop and that their event handling might not be compatible, but just in case, can someone have a more definitive answer?

Edit:

Actually, it's much better when using openPopup:

Toolkit.openPopup( { x:20, y:150, width:100, height:100 }, function(root:Root) {
            var view:IDisplayObject = Toolkit.processXmlResource("assets/xml/haxeui-naming.xml");
            root.addChild(view);
        });

It's possible to interact with the rest of the screen (managed with HaxeFlixel), but the mouse pointer present in the part of the screen managed with HaxeFlixel remains under the HaxeUI user interface elements.


Solution

  • When you open a fullscreen or popup with haxeui, the program flow will be blocked (your update() and draw() function won't be called). You should probably have a look at flixel-ui instead.