1
$\begingroup$

I've had a lot of problems with dynamic texts and I've been looking for a solution. I've just been wondering, for dynamic texts in the BGE, can I use .png files or not? What would I use? Thanks!

$\endgroup$

1 Answer 1

1
$\begingroup$

There are two methods to show dynamic text with the BGE.

Textobjects

enter image description here

They are easy to setup. You add the textobject, set the text in edit mode and start the game. Changing the text in game can be done via setting the attribute "text" in Python:

import bge
textObject = bge.logic.getCurrentController().owner
textObject.text = "my new text"

or if configured by setting a property called "Text":

enter image description here enter image description here

The faces of the resulting object consists of several quads. The texture is rendered from an font while the game is running. You do no have access to the quads nor the textures.

Bitmaptext

This was the method before introducing the text objects (see above). A bitmap text object is a plain plane object.

enter image description here

You need a specific material setting Game Settings/enable Text:

enter image description here

Addional you need a special image as texture. It has meta informations regarding each single character encoded in the top line of the texture.

enter image description here

These data should never ever be changed. This also means you need an image format with lossless data compression such as .png or .tga (never jpg).

The UV mapping of the quad should fit the first character in the texture which is an @ character. This is the maximal bounding of an character. The BGE will derive the size of all other characters from this setting.

enter image description here

You can generate such textures with a tool called "FTBlender" from fonts of your OS. Alternative you can search the internet for bitmap text images.

This method allows you to manipulate the image of each single letter as long as you leave the metadata unchanged. This way you can get very artistic and colored characters.

I hope it helps

PS: here is a sample image- baloon.png:

enter image description here

$\endgroup$
5
  • $\begingroup$ Thank you for all the information, it all helped. How can I use FTBlender? I can't seem to find a bitmap text image as you have on the web. I have font I downloaded that I want to turn into bitmap text. Thanks! $\endgroup$
    – blackhole
    Aug 5, 2015 at 13:12
  • $\begingroup$ As far as I can remember you need Blender 2.49b and FTBlender. You extract the FTBlender.zip into the Blender installation directory. Then you open Blender and load the ftblender.blend file (it is an helper to the ftblender.exe) and you run the python script via <ALT+P>. A window will open showing a preview of the font. You can get help via <?>. $\endgroup$
    – Monster
    Aug 6, 2015 at 6:04
  • $\begingroup$ I've tried many times and I keep getting the @ character repeating behind itself. Can you post a .blend? $\endgroup$
    – blackhole
    Aug 8, 2015 at 4:03
  • $\begingroup$ I have some problems with that too. It works when I append an object from an old file (2.42). ... let me investigate a bit more ... $\endgroup$
    – Monster
    Aug 10, 2015 at 7:25
  • $\begingroup$ Alright, I appreciate it! :) $\endgroup$
    – blackhole
    Aug 10, 2015 at 19:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .