Page 1 of 1

destroying a timer in an other actor?

PostPosted: Sat May 07, 2011 8:07 am
by sonicfire
so you can create a timer in a different actor (or from any other actor) but how can you destroy it?
i have a gameover actor with constant timer actions and when i click on my TOUCHREGION actor
i would love to use something like :

Code: Select all
DestroyTimer("gameOver", "1secTimer");


so that it would destroy the timer in the gameover object.
ANy workarounds? :)

Thanks!

Re: destroying a timer in an other actor?

PostPosted: Sat May 07, 2011 8:10 am
by sonicfire
this also doesnt work :oops:
Code: Select all
gameOver->DestroyTimer("1secTimer");


But isnĀ“t gameOver a pointer in this case ?

Re: destroying a timer in an other actor?

PostPosted: Sat May 07, 2011 8:13 am
by skydereign
There are, but that really should be fixed. Any of the functions should be actor specific, the reason I had to come up with this particular workaround is because getAnimName isn't actor specific. Anyways... use an activation event. If you didn't know, these are extremely useful. Send the activation event to the actor you want to have its timer destroyed, and it will do it. The trick though is setting a variable of the actor you are sending the event to, so it knows how to act. For example, if you have two timers, and would like to destroy either one, depending on the situation, have a variable activateType.

Code: Select all
activateType=1; // destroy timer1
SendActivationEvent("actor");


actor -> Activation Event -> Script Editor
Code: Select all
switch(activateType)
{
    case 1:
    DestroyTimer("timer1");
    break;

    case 2:
    DestroyTimer("timer2");
    break;
}
activateType=0;

Re: destroying a timer in an other actor?

PostPosted: Sat May 07, 2011 8:22 am
by sonicfire
i got it working simply by using activation events with mouselclick and stuff :)

EDIT: Wow, that was quick, let me read your post :D
EDIT2: Excellent idea, i will do it exactly this way now :) Thanks a million!

Re: destroying a timer in an other actor?

PostPosted: Wed May 11, 2011 5:13 pm
by Camper1995
Or I just created another timer that destroys the another one and itself. :p

I know, you'll have mess in timers abut it's pretty fast and it works ^^

Re: destroying a timer in an other actor?

PostPosted: Thu May 12, 2011 5:12 pm
by sonicfire
Camper1995 wrote:Or I just created another timer that destroys the another one and itself. :p

I know, you'll have mess in timers abut it's pretty fast and it works ^^


hey that idea is quite good!! :lol: