Reputation: 1327
I am trying to create a hexagon on the screen in my LWJGL game. I am using Nifty GUI. I currently have 2 screens, and I want to switch to a screen where I programmatically draw hexagons.
Here is my xml for the screen
<?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">
<useStyles filename="nifty-default-styles.xml" />
<useControls filename="nifty-default-controls.xml" />
<screen id="start" controller="StartScreen">
<layer id="background" childLayout="center">
<image filename="util/img/menuTexture.png" />
</layer>
<layer id="title" childLayout="vertical">
<image align="center" height="20%" width="80%" filename="util/img/title.png" />
<panel id="subactions" childLayout="absolute" marginTop="40%" height="13%">
<image align="left" height="100%" width="30%" x="0px" y="0px" filename="util/img/rules.png">
<interact onClick="showRules()" />
</image>
<image align="right" height="100%" width="30%" x="70%" y="0px" filename="util/img/exit.png">
<interact onClick="exitGame()" />
</image>
</panel>
<image align="center" height="20%" width="80%" filename="util/img/start game.png" marginTop="5%">
<interact onClick="startGame()" />
</image>
</layer>
</screen>
<screen id="rules" controller="StartScreen">
<layer id="background" childLayout="center">
<image filename="util/img/menuTexture.png" />
</layer>
<layer id="transparent" backgroundColor="#D1D1D1A7" childLayout="vertical">
<panel id="rulesPanel" childLayout="center">
<image filename="util/img/game rules.png" width="100%" height="100%" />
</panel>
<panel id="goToStartPanel" childLayout="center" width="100%" height="13%">
<image height="100%" filename="util/img/exit.png">
<interact onClick="goToStartScreen()" />
</image>
</panel>
</layer>
</screen>
How do I switch to such a screen (would I use nifty.gotoScreen() ?) and initialize the render loop?
Any example code would be helpful. Thank you very much.
Upvotes: 0
Views: 217
Reputation: 1356
Yes, you always use nifty.gotoScreen() to switch to a different screen.
But I don't really understand the drawing shapes part ;) Current Nifty, 1.3.x or 1.4.x don't support custom drawing to a screen. But no one prevents you to render other things before or after you call nifty.render() which makes things appear below or above the elements rendered by Nifty.
If you want to have some elements directly on the Nifty screen custom drawn by you your only chance would be to get hold of a texture that Nifty renders and render to that texture on your own (outside and without any help from Nifty). Nifty will just display the texture as an image element for instance but you could have change the content of the texture outside of Nifty.
Does that make sense?
Upvotes: 0