Game Development Community

GUI text in front of everything else

by Philip Mansfield · in Torque Game Builder · 06/06/2006 (12:43 pm) · 7 replies

I've got a bit of a problem with my current project. The screenshot below shows it:
www.philspcmods.com/T2D/guitextover.jpgI have the pig on layer 1, group 1. The bomb is on layer 5, group 5.

For each bomb I create a new sceneObject, and attach some GUIs to it. Then I mount the sceneObject on the bomb.

Everything is hunky-dory apart from the fact that the GUI text mounted to the bomb appears in front of the player. What's the easiest way to get that GUI text to be on the same layer as the bomb so that it doesn't appear in front of the player?

#1
06/07/2006 (12:03 am)
Of course the first obvious way is to create bomb sprites with all possible numbers and swap out the images as the bomb values change.. I'm sure somebody more clever than me can figure out a better solution...

Then if all your bombs are derived from a bomb class.. you could do something like..

function bombClass::changeBomb(%this,%val)
{
      %this.setImageMap(%val@"bombImageMap");
}

$blackBomb.changeBomb(21);
#2
06/07/2006 (12:13 am)
You could also use bitmap fonts, and just mount them to the bomb set to the numbers you need, there was a thread with some pretty cool bitmap font scripts a while back. Or just make images for 0-9 and do it that way instead of a full blown text system. :D
#3
06/07/2006 (2:10 am)
I saw the thread on bitmap fonts when it was posted, and it was cool, but it required engine changes, and I don't know if it will work with RC1. My C++ skills are almost non-existant so I doubt I'd be able to get it working.

Images for the numbers were my second choice, and if I can't get the GUIs to appear on the right layer, that's what I'll do.
#4
06/07/2006 (9:31 pm)
Actually the one I;m using doesn't require engine modifications, you have a variable that holds all the characters you're using: $chars = ABCDEFG; etc.. and then the script takes your string that you want to write, and steps through it for each letter, finds the matching letter in the variable of the alphabet ($chars), and uses the position of the single character in that alphabet variable to grab the correct frame from an image map. I totally didn't explain that well... but heres the link!

www.garagegames.com/mg/forums/result.thread.php?qt=27090
#5
06/08/2006 (12:19 am)
My knowledge may be outdated by changes beyond 1.02 which is the version I'm most familiar with, but I don't think you can integrate a GUI control down into a specific scene window layer. Since the scene window itself is a gui control, other GUI objects by nature are either completely behind, completely in front, or in front by virtue of being a child control of the scene window gui object.

I'd recommend following Ezra's suggestion. You get text that will nicely and seamlessly scale with resolution/sprite sizes, are color-blendable, and if you extend the implementation just a little, you can do some neat tricks (all without engine modification).

For example, if you mount each character in your string to the one before it, and set the mount elasticity to a non-zero value, you can fly your text around with some neat 'springy' effects. Sprite-based ext can be easily rotated too, unlike gui text. It's also easier to get complex font apperances (like drop-shadow on the letters) by baking it into the png, which would require some effort to duplicate using a standard font converted to the torque bitmap font format.
#6
06/08/2006 (12:40 am)
I'll check it out then. There must have been another post on bitmap fonts that required engine changes and I got them confused.

Thanks :)
#7
06/08/2006 (1:57 am)
Excellent, I've got that plugged in and working like a charm.

Thanks for the help guys :)