Page 1 of 1

stopping timers

PostPosted: Sat Apr 25, 2009 7:49 pm
by j2graves
okay, there's an event that starts a timer, but there is supposed to be a way to stop that timer. how can I cancel a timer?

Re: stopping timers

PostPosted: Sat Apr 25, 2009 9:37 pm
by jimmynewguy
DestroyTimer("timer"); :lol:

Re: stopping timers

PostPosted: Sun Apr 26, 2009 12:36 am
by j2graves
thanks, +1

Re: stopping timers

PostPosted: Thu Aug 18, 2011 3:28 am
by ikarus
I keep trying this but my timer goes on forever??? It even returns true???

Re: stopping timers

PostPosted: Thu Aug 18, 2011 4:26 am
by skydereign
You can make timers go on forever, or any number of times, but using DestroyTimer will destroy the specified timer for the event actor. It should be just like jimmynewguy says. The only tricky thing is that you can't destroy other actors' timers.

Re: stopping timers

PostPosted: Fri Aug 19, 2011 6:30 am
by ikarus
Hmm... It's not working for me. What's going on is I have an activation even that triggers the creation of a timer that has a 5 count. That goes on forever by the way anyways. So I tried DestroyTimer() to end it on the fifth count, that doesn't work either. But it's fine for now, I worked around it. I just have a variable now, and whenever it's true the timer event does something, otherwise it does nothing.

Re: stopping timers

PostPosted: Fri Aug 19, 2011 7:21 am
by skydereign
Here is an example of what you just described, more or less, with the DestroyTimer working. On the create actor, it sends an activation event to itself, which creates an infinite timer. Each iteration of the timer, it moves the actor 10 pixels. To stop it, click the actor, which calls DestroyTimer.
http://game-editor.net/media/kunena/attachments/66/destroy_timer.zip