Quick GUI Manipulation Cheat Sheet: NOW Direct Label Access

Quick GUI Manipulation Cheat Sheet:

Update each element after manipulation !


Change a Text on a Label:

Label textField = nifty.getScreen(screen).findNiftyControl(elementName, Label.class);

Change the value of X and Y

element.setConstraintX(new SizeValue("20px"));
element.setConstraintY(new SizeValue("20px"));

Change the value of width and height

element.setConstraintWidth(new SizeValue("20px"));
element.setConstraintHeight(new SizeValue("20px"));

I’ll update this to make a small online cheatlist

1 Like

You grab the element and set the constraints.

element.setConstraintX(new SizeValue("20px"));
element.setConstraintY(new SizeValue("20px"));

You have to call reset layout afterwards and then I don’t think the result is immediate so you can’t immediately call getX() and get the correct value.

1 Like

So i now want to manipulate the inside text and the width, so it shows nicely.
The way i do looks a bit rubbish ! And it’s a little bit… unsafe while reviewing my scene.

Is there a better way to access these two values than this, while they are on the same Element and i am making two objects handling this ?

    nifty.getScreen(screen).findNiftyControl("labelName", Label.class).setText(myText);        
    Element sceneElement = nifty.getScreen(screen).findElementByName("labelName");
    sceneElement.setConstraintWidth(new SizeValue("500px"));       

What i’d like to achieve is, to make some … teasing title for the title, like in a movie or a trailer
This trailer is chosen by about no other interest, than it uses font to underline, what we are seeing, accordingly to what i want to try.

There’s a script when to show what where. But it doesn’t render accordingly. Any ideas about this ?

My approach chosen was taking at least 2 to 4 labels, texting them, sizing them and positioning them. But it’s not that easy like just putting some Subtitles together. It’s weird !

I can work it in easily into the trailer itself, but then i am loosing some nice functionality …
I would really like to master this ^^

Perhaps nifty is not the best approach for this particular type of text. Even BitmapText would seem to provide the basics of what you need without getting in the way though there are even some slightly more user-friendly alternatives depending on your requirements.

I managed making a video.
It is without sound, because i only attached the VideoRecordState, but you can see, what i am doing. Btw.: i already thought about putting them into the video completely, but as those labels can be clicked, that was a nice gimmick of interest for me too …

Here’s my small trailer:

It’s uploading for some minutes, so give it a chance :wink: Link is already up.

This isn’t my main concern right now, but i thought it looked damn easy to do that.

I had a different approach, which was working well too, where i had to setup a new label
for every actionScene i had, giving it an empty string of length, what would be length in characters later too.
Switching that around worked quite good, if i didn’t speed up too much, which is … by choice, a wanted feature too.
The lines should come up and make you read, rather than having a star wars scrolling intro.

By now, this is about 2 weeks of progress in learning very very much around JME3, but i like it like i liked JME2 and 1 :wink: