Game Development Community

Placing text at a specific location inside the world

by Corey Martin · in Torque Game Builder · 03/08/2005 (2:56 pm) · 7 replies

I'm trying to put together a 'floating text' function which will flash a short a text message (actually, a number with + or -) at a specific point in world coordinates (directly above an object, more specifically). I first figured I would just use the Gui system and create a text control. This is all well and good, but I can't figure out a good way of placing that Gui control at a particular spot within the world, considering the Gui elements seem to be using real screen coordinates as opposed to world coordinates. This does make sense, however it's not the sort of behavior I need for my function.

I suppose my question is, is there a way for me to position a Gui control in world coords, or do i need to use some sort of bitmapped font and construct the string with images (seems like a pain, i'd rather leverage existing t2d tech)?

#1
03/08/2005 (4:24 pm)
If you want the string to appear in the 2D World.. you should probably consider using sprites.

It will only be a pain for the initial setup, after that it should be no problem. After that initial setup... you should be golden.
#2
03/08/2005 (5:49 pm)
Ok, thanks for the advice. I'll get cracking. :)
#3
03/08/2005 (5:58 pm)
Just to continue a bit... You have two choices you can do. 1. Fixed strings, single sprite. or 2. Arbitrary string length single sprite per letter.

For case 1 you would pass the ID of the score to show, and the world location to display at.
For case 2 you would pass the String to display and the world location to display at
#4
03/08/2005 (6:24 pm)
Case 2 is definately the desired option :) In my experience, the less static your resources the better. I suppose it's just a matter of writing a simple, single character string parser. Any suggestions on useful TorqueScript functions for this sort of thing?

Edit: 60 seconds of browsing through the torque docs and i've found everything I need. :)
#5
03/09/2005 (4:19 am)
I'll be creating in-world text capabilities for T2D so you won't have to do this stuff.

You can easily write a simple function to display arbitrary text using sprites and create some cool effects as well!

Here's LabRat's help on producing in-game text for now though.

- Melv.
#6
03/09/2005 (4:58 am)
Got it written in next to no time. Now that im using imagemaps instead of trying to hax the Gui controls, i can do *lots* more with it (fancy fades and outlines and such). Definately the better of the two options, anyway :)
#7
03/09/2005 (5:26 am)
Excellent, good to hear.

- Melv.