making text boxes, and stuff...

I load an image (which is really a flat egg model):

image = loader.loadModel( "image" )
image.setPos(x,y,z)
image.setScale(x,y,z)
image.reparentTo( aspect2d )
image.setBin("fixed", 40) # btw, why 40?

And then I load text on it:

text = TextNode("node name")
# load a text file to read from
textfile = open('textfile.txt')
text.setText(textfile.read())
textNodePath = aspect2d.attachNewNode(text)
textNodePath.setScale(x)
textNodePath.setPos(x,y,z)
text.setTextColor(0,0,0,1)
# wordwrap
text.setWordwrap(16)

Now it looks pretty cool and all with so little coding.
But I need a way to count the lines (generated by wordwrap) somehow, so the text wont go all over the screen,I will be able to load it like 4 lines each time. How can I count the lines?

text.getNumRows() returns the number of text rows, text.getHeight() returns the height of the text in Panda units (often the same as text.getNumRows(), if your font height is 1.0), text.getBottom() returns the Z coordinate of the bottom of the text.

All of this is described in the generated API specs for TextNode.

David

Thanks

Where is that?

Click “Reference” at the top of this page.

David