Game Development Community

sceneObject problems

by Sam.E · in Torque Game Builder · 01/14/2010 (10:28 pm) · 4 replies

While making my game, I encountered a rather weird problem. I have a few textObjects on screen, they basically there so the player knows whats going on when. But 1 major problem comes up, when I change a textObjects text to the players opponents name (example) it gives me a whole bunch of weird symbols, there is no errors in the console, my code is below:

function StartupGame()
{
	CreatePlayers();
	SetupBoard();
}

function CreatePlayers()
{
	$player1 = new t2dSceneObject()
	{
		class = "player";
		opponent = $player2;
		name = "Player";
		rolls = 5;
		movement = 14;
		powerups = 2;
	};
	
	$player2 = new t2dSceneObject()
	{
		class = "computer";
		opponent = $player1;
		name = "Computer";
		rolls = 0;
		movement = 0;
		powerups = 0;
	};
}

function SetupBoard()
{
	Turn.text = $player1.opponent.name;
}

That isn't the exact code but it gives the same result, the textObject's name is Turn and the player1's opponent's name comes out with a lot of weird symbols instead of Computer, any help would be appreciated.

Please don't mention to put $player2.name instead of $player1.opponent.name because the above code is just an example, I have some code where I can't put $player2.name.

#1
01/14/2010 (10:59 pm)
I think I might see the problem - $player2 doesn't have a value yet when you create the first player object because the second sceneobject hasn't been created yet. That's probably why you are getting some weird symbols because it's pointing to some junk.

I would try to initiate those values after both objects have been created, such as -

# $player2 = new t2dSceneObject()
# {
# class = "computer";
# opponent = $player1;
# name = "Computer";
# rolls = 0;
# movement = 0;
# powerups = 0;
# };

$player1.opponent = $Player2;
$player2.opponent = $player1;
#2
01/14/2010 (11:04 pm)
Hehe, how silly of me not to see that :P Thanks it worked. Oh one more question, I have a custom font in my game, now I've heard but no one has confirmed that the font wont work on any other computer (mac and pc) unless they have that specific font installed. Is this true?
#3
01/14/2010 (11:05 pm)
Yes that's true as far as I know, I believe TGB will pick up the font if it's simply installed on the system. You will need some kind of installer program for your game so you can install your font when the game installs, or at least that's how I'm doing it.
#4
01/14/2010 (11:13 pm)
Okay thanks!