Game Development Community

Whack-A-Mole issue

by Matthew R. Jones · in Torque Game Builder · 07/15/2006 (11:38 am) · 4 replies

Greetings everyone!

I'm having an issue with the whack-a-mole tutorial. After my moles dive back into the hole, they just sit there. The last frame of the animation just sits there. At no point are they deleted, and they clog up the respawn point. Any ideas of what's going on?

Thanks,

- Matthew

#1
07/15/2006 (5:09 pm)
Did you maybe somehow delete, corrupt or overwrite the onAnimationEnd() callback?
#2
07/16/2006 (4:48 am)
I ran into the same problem going through the tutorial. I found that that delete is not called in mole::onAnimationEnd for the divein animation. I find it odd that it works on some systems and not others.
I tried it on 2 different systems and it works fine on one but not the other. Anyway here is what I did to resolve the problem.

In the mole::onAnimationEnd callback you need to add an OR condition for the divein animation in the if statement and that will allow it to delete the image.

function mole::onAnimationEnd(%this)
{
   if(( %this.getAnimationName() $= ("animMoleWhacked" @ %this.moleColor)) || %this.getAnimationName() $= ("animMoleDiveIn" @ %this.moleColor))
   {	
      // free the respawn point for other moles
      %this.respawnPoint.isOccupied = "";
      
      // decrement the occupied counter
      %this.sceneGraph.spawnPointsOccupied -= 1;
      
      %this.sceneGraph.schedule( 1500, "spawnMole");
      %this.safeDelete();
  }
}

hope this helps.

~Guy
#3
07/17/2006 (7:30 am)
Thanks for this.

I hit the same stumbling point in the tutorial, but had forgotten how to format the or statement. I had instead copied the code into the diveIn function, but your's looks much better.
#4
07/25/2006 (4:10 pm)
An alternate solution is to replace the first line with a not equal check to the animation name. If the animation that is ending isn't the one for the mole coming out, then the mole must be getting replaced (either whacked or diving back into the hole.

function mole::onAnimationEnd(%this)
{
   if( %this.getAnimationName() !$= ("animMoleComeOut" @ %this.moleColor) )
   {
      // Free the respawn point for other moles
      %this.respawnPoint.isOccupied = "";
      
      // Decrement the occupied counter
      %this.sceneGraph.spawnPointsOccupied -= 1;

      %this.safeDelete();
   }
}

- Dave