destroying a timer in an other actor?

Non-platform specific questions.

destroying a timer in an other actor?

Postby sonicfire » Sat May 07, 2011 8:07 am

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!
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Re: destroying a timer in an other actor?

Postby sonicfire » Sat May 07, 2011 8:10 am

this also doesnt work :oops:
Code: Select all
gameOver->DestroyTimer("1secTimer");


But isn´t gameOver a pointer in this case ?
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Re: destroying a timer in an other actor?

Postby skydereign » Sat May 07, 2011 8:13 am

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;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: destroying a timer in an other actor?

Postby sonicfire » Sat May 07, 2011 8:22 am

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!
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Re: destroying a timer in an other actor?

Postby Camper1995 » Wed May 11, 2011 5:13 pm

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 ^^
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: destroying a timer in an other actor?

Postby sonicfire » Thu May 12, 2011 5:12 pm

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:
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest