Hi i wanted to know if there is some way to make your text BitmapText to be allways at a center of a geometry , lets say a cube(1,1,1) .
When i try to do some thing similar its allways moving to the right or to the left , im not posting my code couse its totally failed , but idea would be like
this way only first letter is in the center all others are going to right, what i would like to obtain is to put a center of text at center of box
your way i just make string start from center
I’m not on my pc so I can’t get all fancy, but get the bounding volume of the label and convert it into a BoundingBox. That will give you the half-length on the x axis, so shift the label left that amount.
myText.setLocalTranslation(-(myText.getLocalScale().getY()/0.7f0.24fs.length()),
y ,// (line-1) -((myText.getLocalScale().getY()/0.7f0.44f))
0.5f);
this line is crazy, unexpected, random value one that anyway dont solve anything trully, it just work for single situation.
idk why you dont even use “aligment”(txt.setAlignment() and txt.setVerticalAlignment()) that do center for you. Here is some code that you can see use aligment for BitmapText class. But to use it you have to set proper Box for your BitmapText where it will be centered. If you were doing anything in HTML, its similar to aligment in there.
Its not crazy , all you need to know is scale of a letter and an X and Y values you need to give it to put it at center , than you just apply proportion, i have allready tested it with different sizes and lenghts , soo its good for multiple lines as well , while i have not tested your code yet, all i’ve found and read here(exept what you gave) was tested and failed .
well thats is to try , may be the fact i added it after center ,was the thing to breack every thing,
Oh and i did not tested lemurs label , i’ve seen only answer on BitmapText , but will try to add it first as well .
Tried to center BitmapText after attaching it , did not worked as well for lenght sad
Will give a look to lemurs label
If you want Lemur’s label to center before you add it then you can call
label.setSize(label.getPreferredSize());
…for components not in a layout, it will do that automatically when attached to the real rendered scene. Which is why center() after adding it would work, too.