Game Development Community

I have some question about WhackAMole tut.

by Apppothk · in iTorque 2D · 10/11/2010 (4:35 am) · 1 replies

function moleLevel::onLevelLoaded(%this)
{
%this.respawnPointSet = new SimSet();
echo("apple");

}
function respawnPoint::onLevelLoaded(%this, %level)
{
%level.respawnPointSet.add(%this);
echo("apple");
}
when i run the program , the program will not output the apple string.
But if i add onLevelLoaded function into mole class
function mole::onLevelLoaded(%this){
echo("apple");
}

it will output 3 times apple string.

and one more question,the program will not excute "spawnMole" function.

function mole::onAnimationEnd(%this)
{
if( %this.getAnimationName() !$= ("animMoleComeOut" @ %this.moleColor) )
{
// after deleting the old mole schedule a respawn
// >%this.sceneGraph< is the level
%this.sceneGraph.schedule( 1000,spawnMole);
%this.safeDelete();
}
}

function moleLevel::spawnMole(%this)
{
// find a spawn point
echo("testing");
%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";
};

// play right animation according to the color
%mole.playAnimation("animMoleComeOut" @ %color);


// save the selected color as dynamic field
%mole.moleColor = %color;

// set the position of the mole to the position
// of the respawn point
%mole.setPosition( %respawnPoint.getPosition() );
}



#1
02/08/2012 (1:10 am)
did u solve your problem ?
ive got the same thing with tgb 1.7.6