Text and background image

hello , according to that code :



[xml]

<panel id=“menu” height=“35%” width=“35%” align=“left” valign=“bottom” childLayout=“center”>

<image filename=“Textures/Interface/fondmenu.png” ></image>

<text id=“text” font=“aurulent-sans-17.fnt” color="#ffff" text=“Hello World” align=“left” valign=“bottom” />

</panel>

[/xml]



The text is out the image , can anyone tell me what is wrong ? align and valign are the same in panel and in text i don’t understand why it doesn’t work



Thanks

i’m trying here to set up a menu , do you think i should use as many image as i need things in my menu ? like image for Start image for Continue etc … ? or do you think it’s better for me to have a background image with text inside ?

Hi there, the problem with your xml is that the childLayout=“center” only works with the very first child element. The only element that the “center” layout cares about is the very first child.



You can easily add a childLayout=“center” to the image and use the text element as a child of the image element. This should center it properly in the image which itself is centered in the panel.



About your second question what’s the best way for a menu the answer is, it depends :slight_smile: Your initial xml should work ok for a small number of menu items. If you need more menu items or more flexibilily your own custom Nifty control would probably work pretty well.



There was an in depth tutorial added to the nifty wiki at sf.net which explains this in detail: http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Create_your_own_Control_%28A_Nifty_Progressbar%29. It described a progress bar but it should get you started in any control basically. The idea would be to have your own “menu-item” control. You could even have individual images for each menu if you want to.

1 Like

thanks for your answer , i understand that you did everything with the controller=“de.lessvoid.nifty.examples.progressbar.ProgressbarControl”



Anyhow i don’t know how to use the controller , or should i only use "de.lessvoid.nifty " ?



Thanks

The controller is just a implementation of some Nifty Java interface that Nifty uses to talk to your control. It’s the part that connects everything together. You can use your own class which can be in any package that you want.



You’ll just need to create a class with:



[java]package my.cool.stuff;



public class MyController implements de.lessvoid.nifty.controls.Controller[/java]



and give the name of that class with the full package to Nifty in your controller definition in the xml:



[xml]<controlDefinition name=“mySuperNiftyControl” controller=“my.cool.stuff.MyController”>[/xml]



And whenever Nifty wants something from your Control or it wants to notify you of some stuff then this class and it’s individual methods are being called.

1 Like

Thanks for your answer ,



Do you think it’s hard to do menu that invokes menus like this video ?