Question about WhackaMole in documentation
by Raymond Clark · in Torque Game Builder · 08/23/2010 (7:07 pm) · 1 replies
Hi all. I have a question about the whackamole Doc. Here is an excerpt.
function moleLevel::spawnMole(%this)
{
// find a spawn point
%respawnPointIndex = getRandom( %this.respawnPointSet.getCount()-1 );
%respawnPoint = %this.respawnPointSet.getObject( %respawnPointIndex );
// select a color for the mole
%color = getRandom(2);
if( %color == 0 )
%color = "red";
if( %color == 1 )
%color = "green";
if( %color == 2 )
%color = "lilac";
// create a new Mole
%mole = new t2dAnimatedSprite()
{
sceneGraph = %this;
class = "mole";
layer = 4;
size = "9 16";
};
My question is, how is it possible for %color to be a number then into a string. It first becomes a random number, if it equivalant to 0, then it changes into a string red. Am I on the right track with this?
function moleLevel::spawnMole(%this)
{
// find a spawn point
%respawnPointIndex = getRandom( %this.respawnPointSet.getCount()-1 );
%respawnPoint = %this.respawnPointSet.getObject( %respawnPointIndex );
// select a color for the mole
%color = getRandom(2);
if( %color == 0 )
%color = "red";
if( %color == 1 )
%color = "green";
if( %color == 2 )
%color = "lilac";
// create a new Mole
%mole = new t2dAnimatedSprite()
{
sceneGraph = %this;
class = "mole";
layer = 4;
size = "9 16";
};
My question is, how is it possible for %color to be a number then into a string. It first becomes a random number, if it equivalant to 0, then it changes into a string red. Am I on the right track with this?
About the author
Torque Owner Kevin James
It doesn't matter a hill of beans to the compiler but its easier to follow for us humans.