Game Development Community

Implementing game logic as text

by Laralyn McWilliams · in Torque Game Builder · 03/14/2006 (8:01 pm) · 1 replies

I'd like to prototype some of the behaviors for the game I'm making to nail down the theories before I start trying to make graphics. I can use dots for characters, but how do I display "live" text on the screen?

Here's an example. Imagine you were trying to make an RPG, where you go up to a shopkeep, and click on him to interact with him. When you click on him, a speech bubble appears over his head with his greeting.

Is there a way in T2D to display/change the text in that speech bubble?

Is there a way to have multiple lines of "live" text, and to change the text on the fly?

Thanks for any pointers toward places to look for this info. :-)

#1
03/14/2006 (9:24 pm)
You have a few options. First, you could use standard Torque GUI objects, like GuiMLTextCtrl. These can contain multiple lines of text that you can set realtime, and even have some nice markup features such as indescriminate font/size/color/margin setting, and even hyperlinks (nice for RPG interactive speech stuff). Fire up the Gui tool and create a GuiMLTextCtrl and save it out. You can then use the Canvas.pushDialog() to display it, then setText() on the GuiMLTextCtrl to dynamically set the text from script. There's lots and lots of examples of this to search on since it is also what TGE uses.

Another option is to actually use sprites for the individual characters. This doesn't work as well with lots and lots of text, especiall multi-line, without a good amount of work. There are a few resources published on how to do this. Basically you use one PNG file that contains all your letters/numbers/symbols and map them out and use a few functions to convert strings into collections of sprite objects. The advantage here is you can do all the T2D-like things to the text and they integrate smoothly into the rest of your sprite stuff.