Hi there. I’m trying to use a textbox to limit the line length of a text object. In the 3d view it works just fine, but the moment I press P to try it out, it’s as if the textbox doesn’t exist. Also the position and shape of the text are slightly skewed. Does anyone know how to fix these problems?
As @Cotaks said, the textwrap module is the way to go.
There’s an article I’ve written about text formatting in BGE here, you may find it helpful, it explains how to use textwrap and left / center / right formatting. It’s in portuguese, but Google Translation in Chrome showed a good result in english for me.
i made line break work with string property using this method. (if any needs it)
import bge
cont = bge.logic.getCurrentController()
own = cont.owner
def stringpropfix(txt=""):
tmp = txt.split('\\n')
t = ""
for line in tmp:
t += line + "\n"
return t[:-1]
own["Text"] = stringpropfix(own["txt"])