How to update text in a GUI?
by Ray Depew · in Torque Game Builder · 09/15/2007 (4:46 pm) · 2 replies
This is probably something really simple, but I haven't figured it out yet.
I'm writing a side-scrolling game, a la Mario Brothers. When the player's character encounters other characters, they can have a conversation and the words are shown in a word balloon above their heads. The player can step through the conversation by pressing a key, such as Space, Enter, or whatever. That part I'm okay with.
What I'm having trouble with is this: the text of the conversation is displayed in a guiTextControl called wordBalloonText. When the player presses the key, I change the contents of wordBalloonText.text , but the new text doesn't appear in the word balloon.
I have verified that wordBalloonText.text contains the new text. I can make the new text appear by making wordBalloon.text invisible and then visible again, so I know I need to update or redisplay the guiTextControl. How do I do that?
(Or is there a better way to do this? I could use T2D/TGB's text object instead. Which is better?)
--
Ray
Edit: Nevermind. I was thinking I'd need some kind of forceUpdate statement, because the simpler methods weren't working. The simple stuff works new.
I'm writing a side-scrolling game, a la Mario Brothers. When the player's character encounters other characters, they can have a conversation and the words are shown in a word balloon above their heads. The player can step through the conversation by pressing a key, such as Space, Enter, or whatever. That part I'm okay with.
What I'm having trouble with is this: the text of the conversation is displayed in a guiTextControl called wordBalloonText. When the player presses the key, I change the contents of wordBalloonText.text , but the new text doesn't appear in the word balloon.
I have verified that wordBalloonText.text contains the new text. I can make the new text appear by making wordBalloon.text invisible and then visible again, so I know I need to update or redisplay the guiTextControl. How do I do that?
(Or is there a better way to do this? I could use T2D/TGB's text object instead. Which is better?)
--
Ray
Edit: Nevermind. I was thinking I'd need some kind of forceUpdate statement, because the simpler methods weren't working. The simple stuff works new.
#2
09/20/2007 (11:46 am)
Yes, I did get it working. It's weird. I was using wordBalloonText.text = "blah" instead of setText. First it wasn't working, and then it was. Thanks for your suggestion.
Torque 3D Owner Matthew Langley
Torque
Try setText and setValue.