Text background

Is there a way to have BitmapText to have a background? or some sort of text to have a background?

BitmapText plus a Quad that is sized to the text.

so i could use getlineheight and getlinewidth correct?

@phantomliger11 said:
so i could use getlineheight and getlinewidth correct?

Yes.

If the string displayeyd on your Bitmaptext changes, simply also update the quad to the new size of your BitmapText.

So how do I set its position, because it doesnt seem to have any function for that?..im a tad confused by that.

As you do with all spatials: setLocalTranslation().

Which “it” do you mean in this case? The Quad has to be put in a Geometry or you can’t even add it to the scene. And you can put the Geometry anywhere you want.

ooo. ok. i didnt realize it needed to be in a geometry. ill try that.

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies any1? :smiley:

Ok. Is there any other way to have a background to Bitmaptext that is actually on the screen? instead of in the game world, or can i put the text (which are numbers just for clarification) into the game world instead of on the screen?



And i dont think that scenegraph for dummies would really help with the situation. i knew everything that was in there. it was just one of those dumb moments where i didnt see that i needed the quad to be attached to a geometry so i didnt know it.

@phantomliger11 said:
And i dont think that scenegraph for dummies would really help with the situation. i knew everything that was in there.


@phantomliger11 said:
Ok. Is there any other way to have a background to Bitmaptext that is actually on the screen? instead of in the game world, or can i put the text (which are numbers just for clarification) into the game world instead of on the screen?

You could do that but for readability you should probably use cam.worldToScreen() to move them on the screen in the gui node instead.
@phantomliger11 said:
Ok. Is there any other way to have a background to Bitmaptext that is actually on the screen? instead of in the game world, or can i put the text (which are numbers just for clarification) into the game world instead of on the screen?


There is no difference between things in the gui and things in the world except what root node you attach them to.

Or one of us is completely misunderstanding the other.

that depends on if worldToScreen() is a function in beta. because i am currently using the alpha 4 version because it crashes in the beat one. which i am trying to fix also. and apparently beta doesnt have cam.setDirection() anymore because it says it doesnt exist on the line that I use that.



I just felt it would be easier for them to be in the game world so I wouldnt have to worry about moving them around on the screen according to where objects are. unless that is made really easy in the beta.



and i guess that does make sense for the dummies page there but the bitmaptext isnt a geometry and it is visible. haha.

Oh yes, bitmaptext is a geometry, multiple even with a quad mesh for each letter. worldToScreen() and setDirection() have not changed between alpha and beta, unless you use them wrong, then anything could happen really ^^

well in the alpha, it says worldToScreen doesnt exist. it says cannot find method worldToScreen

sorry, its called getScreenCoordinates()

ah. im using that.

so in the beta, it says the same thing for cam.setDirection(). that it cannot find the method.

Maybe?

http://hub.jmonkeyengine.org/javadoc/com/jme3/renderer/Camera.html#setRotation(com.jme3.math.Quaternion)



Despite popular misconception, many of us don’t have all of the method names 100% memorized. :slight_smile:



Sometimes it pays to open the javadocs and do a little browsing to find more specifically what we meant.

But the weird thing is that setDirection does exist in the alpha. and so does setRotation. So its a tad weird. I wouldnt figure everyone would know all the names Im just curious why a function is gone.