Game Development Community

GUI score display

by Grimfear · in Torque Game Builder · 09/18/2008 (3:48 pm) · 4 replies

I'm working on my senior project and I need to display scores on the level screen. I'm building a basic side scrolling shooter right now. I tried to adopt the scoring from the behavior shooter but mine is more like the older shooter tutorial on the website. So it didn't work to score points on removal since the object never really gets removed just reset. I tried doing it on collision since that is what triggers the reset but that left the scoring not calculating right.

Basically what I have been trying to find is a way to display a global variable on the screen. Is there a way to do this? I've looked all over the net and can't come up with anything.

Thanks

About the author

Recent Threads


#1
09/18/2008 (10:28 pm)
You could put a t2dText object in your level and use its methods to set it to the score variable whenever that changes. Or you could add a GuiTextCtrl to your GUI (that contains the t2dSceneWindow) and do something similar.

Modifying the score onCollision might not be good since onCollision can get called multiple times per what might look like one "visible" collision. But if you are probably also doing other work in oncollision that should also only happen once you might just fix that by adding a timeout to prevent your onCollision from getting called repeatedly within say, 100ms.
#2
09/19/2008 (10:46 am)
I tried doing the t2dtext object but I couldn't get it to display the variable. I'm guessing there is a specific call in torquescript that might be missing but I can't find it.
#3
10/01/2008 (6:57 pm)
Just name the t2dtext object something like "Score" without the quotes then make its value "Score:" and when you go to add some points do this.

$Score.value = ("Score:" SPC + 1);

thats what I did and it worked for me I hope it works for you!
#4
10/08/2008 (2:45 pm)
Hmm I tried that and its not working. I added the t2dtext object. its text value is set to Score: Where are you setting value? I think this is where I'm messing it up. I don't see a value field per say. Which script do you add the function to update the t2dtext object?

Thanks