Nifty GUI Layout

Posted by Jason Crosby on Game Development See other posts from Game Development or by Jason Crosby
Published on 2012-10-18T16:06:47Z Indexed on 2012/10/18 17:26 UTC
Read the original article Hit count: 272

Filed under:

I am new to JME3 game engine but I know Android XML GUI layouts pretty good. I have a simple layout here and I cant figure out what is wrong. Here is my XML code:

<?xml version="1.0" encoding="UTF-8"?>
<nifty xmlns="http://nifty-gui.sourceforge.net/nifty-1.3.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://nifty-gui.sourceforge.net/nifty-1.3.xsd
                   http://nifty-gui.sourceforge.net/nifty-1.3.xsd">

<useControls filename="nifty-default-controls.xml" />
<useStyles filename="nifty-default-styles.xml" />

<screen id="start" controller="com.jasoncrosby.game.farkle.gui.MenuScreenGui">
    <layer id="layer" backgroundColor="#66CD00" childLayout="center">
        <panel id="panel" align="center" valign="center" childLayout="center" visibleToMouse="true">
            <image filename="Textures/wood_floor.png" height="95%" width="95%"/>

            <panel id="panel" align="center" valign="center" childLayout="center" visibleToMouse="true">
                <text text="test" font="Interface/Fonts/Eraser.fnt"></text>
            </panel>
        </panel>
    </layer>
</screen>

Everything works good until I get to displaying the text. I have tried different alignments and tried moving the text into different panels but no matter what I do the text is never in the center of the screen. Its always in the upper left corner so far I can only see the lower right part of the text. I'm sure it has to be something simple but since I'm new to this I'm not noticing anything. Thanks for the help in advance.

© Game Development or respective owner

Related posts about jmonkeyengine