Beginning tutorial
by Bryan Moscato · in General Discussion · 02/19/2008 (8:18 am) · 5 replies
Yesterday I ran through the Torque 1.5 tutorial but for some reason when I collide with the logos they disapear but do not add to my score.
I set up a guiTextCtrl and named it 'ScoreCounter', set text to 'Score: 0' and changed the font to GuiBigTextProfile.
I edited the file 'GameOne/server/logoitem.cs':
Then I created the file 'GameOne/client/clientGame.cs':
Then I added 'exec("./client/clientGame.cs");' to the 'Client scripts' section of GameOne/main.cs:
Did I miss something?
I set up a guiTextCtrl and named it 'ScoreCounter', set text to 'Score: 0' and changed the font to GuiBigTextProfile.
I edited the file 'GameOne/server/logoitem.cs':
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
datablock StaticShapeData(TorqueLogoItem)
{
category = "Items";
shapeFile = "~/data/shapes/3dtorquelogo/torque_logo.dts";
}
function TorqueLogoItem::onCollision(%this, %obj, %col)
{
if(%col.getClassName() $= "Player")
{
%client = %col.client;
%client.score++;
commandToClient(%client, 'SetScoreCounter', %client.score);
%obj.delete();
%logoCount = logos.getCount();
if(%logoCount > 0)
return;
// otherwise display victory screen
commandToClient(%client, 'ShowVictory', %client.score);
}
}
Then I created the file 'GameOne/client/clientGame.cs':
function clientCmdSetScoreCounter(%score)
{
ScoreCounter.setText("Score:" SPC %score);
}
function clientCmdShowVictory(%score)
{
MessageBoxYesNo("You Win!",
"Would you like to restart the game ?",
"loadMyMission();",
"quit();");
}
Then I added 'exec("./client/clientGame.cs");' to the 'Client scripts' section of GameOne/main.cs:
// Client scripts
exec("./client/optionsDlg.cs");
exec("./client/missionDownload.cs");
exec("./client/serverConnection.cs");
exec("./client/loadingGui.cs");
exec("./client/playGui.cs");
exec("./client/clientGame.cs");
Did I miss something?
About the author
#2
02/21/2008 (5:36 am)
Anyone else have any ideas? I started from scratch with the tutorial and I get the same results; objects on collision are removed but never update the score.
#3
02/21/2008 (7:17 am)
Are you getting any errors in your console.log?
#4
Thanks for the direction. After looking in the log file I noticed that 2 of my functions where unknown. I ended up naming the file clientGame.cs improperly in the client directory, I made it plural (clientGames.cs) on accident. All works fine now.
Bryan
02/21/2008 (8:23 am)
Hey Mike,Thanks for the direction. After looking in the log file I noticed that 2 of my functions where unknown. I ended up naming the file clientGame.cs improperly in the client directory, I made it plural (clientGames.cs) on accident. All works fine now.
Bryan
#5
It's always a good thing to check your console.log when you get errors. It's a great debugging tool.
02/21/2008 (7:28 pm)
That's great. :-) It's always a good thing to check your console.log when you get errors. It's a great debugging tool.
Torque 3D Owner Luiz A D R Marques
Starglider Systems
I've had this one bite me a couple of times.