Game Development Community

Why a working function is anulated when other is called

by Isaac Barbosa · in Torque Game Builder · 01/02/2007 (10:48 am) · 4 replies

Hello TGB community!

Now this is getting worse and I'm tired and mad now (I feel with the brain squeezed)!

I have this function working perfectly:

function Square::onAnimationEnd(%this)
{
	  if( %this.getAnimationName() !$= ("badBallComeOut" @ %this.moleColor) )
	  {
         //Do the right thing accordingly with the piece that was hitted.
		    if( %this.getAnimationName() $= ("badBallWhackedGreen") )
		        %this.countIn();
          if( %this.getAnimationName() $= ("badBallWhackedRed") )
		        %this.countIn();
          if( %this.getAnimationName() $= ("badBallWhackedPurple") )
		        %this.countIn();
          if( %this.getAnimationName() $= ("badBallWhackedOrange") )
		        %this.countIn();
          if( %this.getAnimationName() $= ("badBallWhackedYellow") )
		        %this.countIn();
          if( %this.getAnimationName() $= ("badBallWhackedRay"))
              %this.callray();
          if( %this.getAnimationName() $= ("badBallWhackedBomb"))
              %this.bombexplode();
          if( %this.getAnimationName() $= ("badBallWhackedHeart"))
             %this.countIn();
          if( %this.getAnimationName() $= ("badBallWhackedRock"))
             %this.countIn();
          if( %this.getAnimationName() $= ("badBallWhackedBlueJewel"))
              %this.countIn();
	  }
}

but it seems anulated when this is called to work (and this works as expected but previous stop working)

function Square::onAnimationEnd(%this)
{
   if(%this.getAnimationName() $= ("badBallDiveIn" @ %this.moleColor) && ("badBallDiveIn" @ %this.respawnPoint.lock == false))
   {
      %this.scenegraph.incMissedCountMore();
   }
}

I think the problem lies in the conditional statements settings, but I don't know where the conflict is. Maybe is because I'm calling two onAnimationEnd methods in the same script?

Any help would be greatly appreciated!

Regards

#1
01/02/2007 (11:30 am)
Unless I'm missing something, with the second function declaration, you've effectively overwritten the original function declaration. Why aren't you placing the conditional from the second declaration into the original function declaration?
#2
01/02/2007 (11:43 am)
Just because I believe that I can use two or more onAnimationEnd functions in the same script. Now I now that that's not possible :) Thanks for the clarification. Now I have to deal with the logic to make this works. I will put the answer if I got it.
#3
01/02/2007 (5:29 pm)
If you really want to use the same function but for different purposes - look up "Packages"
#4
01/03/2007 (7:38 am)
@Drew:

Thanks for the tip... Now I have integrated the code into one single function and now it's working as I want it to do. Torque Script it's a bit tricky because I'm new but is easier than I ever think.