FlxUI: any tips?

  • Hey there!
    I am trying to implement a FlxUI in my JRPG prototype, but I can't seem to get a hold of it yet. I'm really struggling with it and I am even considering using FlxTilemaps to design my UI through Ogmo (yeah, I'm a monster).

    So, could anyone please point me in the right direction? A small explanation would do, or any existing online code or videos about it, anything would be appreciated. Just don't point me towards HaxeFlixel demos, because I read their code several times already and ended up more confused than ever.

    Thanks a lot!

  • Apparently, I missed all the info that the repo had to offer on this matter. So now I'm trying to implement the simplest of the FlxUISubStates like this:

    class TestUIState extends FlxUISubState 
    	override public function create()
    		_xml_id = "uiTest";

    And the xml is looking like this:

    <?xml version="1.0" encoding="utf-8" ?>
    	<sprite src="ui/reference" x="0" y="0"/>

    Both assets/gfx/ui/reference.png and assets/xml/uiTest.xml exist, but nothing's being shown in the screen. There's also a FlxState that adds that FlxUISubstate like this:

    override public function create():Void
    		add(new TestUIState());

    And that's it. If I get it to show the image, I feel that I would get on track to proper UI making.

    Thanks a lot!

  • there is a UI demo here, http://haxeflixel.com/demos/Transitions/ that shows how to display things.

  • @galoyo As I wrote in my first comment, I had already read that demo and the RPG Interface one, but found later that the repo for the class was way more clear.

    Today I figured out the problem but not the solution:

    • If I set a FlxUIState as the main state in my game, everything gets displayed correctly.
    • If I set a FlxUISubState as the main state in my game, everything still gets displayed correctly.
    • But, if I set a FlxUISubState as a substate for another main state in my game, whether it's a FlxState or a FlxUIState, nothing gets displayed at all.

    So, is this a bug or am I missing something?

  • I think I fixed it.

    The UI gets created and added when you call super.create(). Everything you add to that state after that line gets rendered on top of the UI so, if you have something like a background, it will block its visibility.

    That, and I was trying to use the constructor to set everything up, not realizing that I needed that super.create function.

Log in to reply

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.