As I didn’t tag this as a support topic, I noticed that I got no replies though all the other posts got really fast replies. So here I post it again. Please help me
Hey there, I have the following problem:
I want to resize a .png image to the panel size. So my Idea was:
I thought the ImageMode=”resize:…” ensures that it is resized correctly (i.e. for buttons don’t resize the fancy corners but only the middle part, as in the Nifty GUI manual page 39)
But instead it forces my image into the panel, distorting it, ignoring my ImageMode-attribute.
I really think that there must be another way to resize this .png so that the xml-file does the resizing correctly, but I can’t find the commands.
Could you help me please?
Hello,
Could you post a screenshot about your button and your gui? maybe the image mode parameters are incorect… or your Interface/button.png is bigger than the actual panel size.
Thanks for sharing! To a first glance as you said seems that the image mode is ignored, is nifty complaining about something? could yuo share also only the image of the button ? I would make some tests!.
About images you have to provide the direct link to the image like this :
Umm, the only complaint I see when running the program is that I don’t have a ScreenController(), but it’s using the default ScreenController() instead.
I’m pretty new to jme, so I don’t really know whether this influences my xml-file, but I actually don’t think so.
And really, I have no clue on how to upload pictures here in the forum… So I’ll just post another link… http://sta.sh/01iqkanjvgtb
Hello it seems that I can’t understand why it’s not working… try with this xml :
[xml]
<?xml version=“1.0” encoding=“UTF-8” standalone=“yes”?>
<nifty xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns=“http://nifty-gui.lessvoid.com/nifty-gui” xsi:schemaLocation=“https://raw.githubusercontent.com/void256/nifty-gui/1.4/nifty-core/src/main/resources/nifty.xsdhttps://raw.githubusercontent.com/void256/nifty-gui/1.4/nifty-core/src/main/resources/nifty.xsd”>
<useControls filename=“nifty-default-controls.xml”/>
<useStyles filename=“nifty-default-styles.xml”/>
<screen id=“GScreen0” controller=“mygame.Main”>
<layer id=“GLayer0” childLayout=“center”>
<panel id=“GPanel0” height=“30%” backgroundColor="#055" width=“50%” childLayout=“center”>
<image id=“GImage1” height=“100%” width=“100%” filename=“Interface/button.png” childLayout=“center” y=“51” imageMode=“resize:50,20,50,48,50,20,50,2,50,20,50,48” x=“139”>
<control name=“label” id=“GLabel0” text=“Tutorial” height=“50px” color="#000" font=“aurulent-sans-16.fnt” width=“100px”/>
</image>
</panel>
</layer>
</screen>
</nifty>
[/xml]
It was generated using the new desing view and there it works as expected . I’ve also set up a little jme project and it works also there.
This is strange… I can’t test again now but when I made it , all works fine both in visual editor and in a real game… I don’t know maybe a complete log of your application would help. Also if you are doing something fancy in the render thread it could influence the nifty render process. Could some other test my xml to see if it works as expected ? I really hope we can find why this isn’t working… !
Ah okay, I could definitely shoot myself in the head right now XD
I found my error while typing my entire xml into this post… i wrote ImageMode=“resize…” instead of imageMode=“resize…”
And as xml is case sensitive, It just ignored the whole ImageMode-attribute…
Of course there was no warning or something. No compiler was designed to tell me that I had written something it didn’t understand…