In-game Text to display score tutorial
by Stephen Sinclair · in Torque Game Engine · 05/02/2007 (12:57 pm) · 2 replies
Hi,
I have a simple question. I found a tutorial a while back on creating a text control in the mission using the GUI editor. The score updates and displays. I can't for like of me remember where that tutorial is. Anybody know where there is a good in-game score keeping tutorial that is basic? I am just now trying to figure out how to update a textbox on the screen while playing the game...
Thanks
Steve
I have a simple question. I found a tutorial a while back on creating a text control in the mission using the GUI editor. The score updates and displays. I can't for like of me remember where that tutorial is. Anybody know where there is a good in-game score keeping tutorial that is basic? I am just now trying to figure out how to update a textbox on the screen while playing the game...
Thanks
Steve
#2
in common/server/clientConnection.cs at the bottom change the incScore function to look like this
then add a new function for example in client/scripts/game.cs or client/scripts/playGui.cs like this
edit: made unclear part more clear
05/02/2007 (1:33 pm)
Felt like being a bit more helpfull so... Here's some code that should workin common/server/clientConnection.cs at the bottom change the incScore function to look like this
function GameConnection::incScore(%this,%delta)
{
%this.score += %delta;
messageAll('MsgClientScoreChanged', "", %this.score, %this);
messageClient(%this, 'MsgMyClientScoreChanged', "", %this.score); // add this line
}in starter.fps/client/scripts/playerlist.cs belowaddMessageCallback('MsgClientJoin', handleClientJoin);
addMessageCallback('MsgClientDrop', handleClientDrop);
addMessageCallback('MsgClientScoreChanged', handleClientScoreChanged);addaddMessageCallback('MsgMyClientScoreChanged', handleMyClientScoreChanged);afterfunction handleClientScoreChanged(%msgType, %msgString, %score, %clientId)
{
PlayerListGui.updateScore(%clientId,%score);
}addfunction handleMyClientScoreChanged(%msgType, %msgString, %score)
{
ScoreHud.updateScore(%score);
}now create a new textCtrl and name it ScoreHud or something (if you use another name change the above function)then add a new function for example in client/scripts/game.cs or client/scripts/playGui.cs like this
function ScoreHud::UpdateScore(%this, %score)
{
%this.setText("Score = " @ %score);
}edit: made unclear part more clear
Torque 3D Owner Vincent D