Game Development Community

How to increase textobject value at run time

by Deepak Sahu · in Torque Game Builder · 08/12/2009 (5:23 am) · 7 replies

Hi,

How to increase textobject value at run time ??
I mean to say how to show score board in screen. i try to echo but it is not display any message to output screen. and how to use this function in onCollision event

function is:
function SetScores(%p)
{
$count += %p;
Score.setText($count);
}

where Score is text object.

About the author

Recent Threads


#1
08/12/2009 (9:10 am)
Echo will send a message to the console which by default you can open with the tilda key. I don't see any problems with your setScores function, it should work fine if you call it in the onCollision event or anywhere else. Are you sure it's being called and that your text object is really named Score?
#2
08/13/2009 (12:28 am)
hi Nate Gertsch,

i call this function in onLevelLoaded, so it work properly but when i call into onCollision then it is not work.
#3
08/13/2009 (9:17 am)
Can you post the code for the onCollision section? I suspect that it's fine and that you're not actually triggering collisions. Are you sure that collision callback is set to true and the objects recieve/send collisions?
#4
08/13/2009 (1:12 pm)
Have you looked in the console? I'm almost certain that the t2dTextObject does not have a setText function. You have to use the fields to set the text like
Score.Text = $count;
It's worth a shot, at least.
#5
08/18/2009 (6:40 am)
function ScoreFile()
{
%file = new FileObject();
if(%file.openForWrite("~/data/files/HighScore.txt"))
{
%file.writeLine($d);
echo("File Written");
currentScore.setText($d);
}
else
{
error("File is not open for writing");
}
%file.close();
}

this function is not work correctly, i means "%file.writeLine($d);" line not work. Any solution ?
#6
08/21/2009 (1:47 am)
Help Me??
#7
08/21/2009 (1:33 pm)
A little more information beyond "I means %file.writeline($d) line not work" would be helpful.

Does it display "file written" in the console?
Does $d have a value?
Is highscore.txt being created?

I get that English isn't your first language but more information makes it easy for us to help you and shows that you've taken a crack at solving the problem yourself.