Having trouble with NiftyGUI

Hello, I’ve been trying for a while to get a HUD working on NiftyGUI but I have had some problems, could anyone point me in the right direction?

Here’s the code:


<?xml version=“1.0” encoding=“UTF-8”?>


<screen id=“HUD” controller=“Controllers.FadeController”>

<layer id=“layer” backgroundColor="#00000000" childLayout=“center”>

<panel id=“panel” height=“100%” width=“100%” align=“center” valign=“center”

backgroundColor="#000000FF" childLayout=“center” visibleToMouse=“false”>

<panel id=“timeLeftPanel” width=“70px” height=“50px” align=“center” valign=“top”

backgroundColor="#00000030" childLayout=“center” visibleToMouse=“false”>

<text id=“timeLeft” font=“aurulent-sans-17.fnt” color="#000f" text=“00” align=“center” valign=“center” />


<panel id=“lapsPanel” width=“70px” height=“50px” align=“left” valign=“center”

backgroundColor="#00000030" childLayout=“center” visibleToMouse=“false”>

<text id=“laps” font=“aurulent-sans-17.fnt” color="#000f" text=“0/0 laps” align=“center” valign=“center” />



<onStartScreen name=“fade” start="#ff" end="#00"

length=“3000” startDelay=“5000” neverStopRendering=“true”/>

<onEndScreen name=“fade” start="#00" end="#ff"

length=“3000” startDelay=“000” />







What I wanted: a semi transparent box of 70x50 pixels on the center-top of the screen, with a “00” text centered on it, and a semi transparent box of 70x50 pixels on the top left corner with a “0/0 laps” text centered on it.

What I got: a semi transparent box of 70x50 pixels on the center-top of the screen, with “00” text centered on it :slight_smile: and a “0/0 laps” text centered on the top left corner (the text is half offscreen on X and Y) with no box at all :frowning:

What am I doing wrong?

Thanks in advance

Just a guess, but on the panel “panel” you have a childLayout set to center, maybe it’s preventing the lapsPanel to be aligned left.

Thank you for your response

I tried removing the childLayour=“center” from the “panel” panel, it still isn’t working quite right, it now shows my two texts on the top-left corner with no box.

A correction: with the code I posted, the second box should be displayed on the left, vertically centered (I think), not on the top left corner as I said.

childLayout “center” only works with the very first child element. it doesn’t care about the other elements and does not layout them at all. Your id=“panel” panel has multiple children and this probably causes you problems.

you’ll need to use an extra panel if you want to use center the way it seems you want to use it. sorry.

1 Like

I see, thank’s a lot void.

I know you do this in your free time, don’t worry :wink:

If I had time myself, I’d take a look at the source instead of asking :stuck_out_tongue: