Runtime Timers
Posted: Tue Mar 06, 2012 4:34 am
I can create a time in Runtime using CREATETIMER. Can I create a timer event handler in runtime?
The reason I am asking is that I need to create a timer after a certain event (Collision). The collision actor is destroyed, however, there needs to be a dedicated timer associated with that particular collision event. Normally not an issue, however, there are clones of the collision actor, which can also have a collision event - spawning new timers, which may occur before the original timer expires.
I don't want to be limited to a prescribed number of collision actors, give them individual names then create a whole lot of timer events attached to the event actor; as for different levels in the game there is going to be a different number of collision actors.
The specific case is when a ball hits a specific actor, the ball shrinks (say to size 2) for a prescribed period of time - before it returns to its original size (size 1). If the ball collides with a clone of the collision actor before the fist timer expires, the ball will shrink further (to size 3) - initating a second time - and so on. Once the first time expires, the ball will grow back to size 2, and once the second time expires, the ball returns to size 1. This is in effect a recusrsive algorithm, which I am not sure gE can accomodate, so is there a work around?
My approach is to create a timer on the collision event with a specific name based on the number of the clone. When that time event occurs, grow the ball up to the next size (managed through a global variable), then destroy the timer. But I need to create a timer event handler for the timer of that specified name.
clear as mud??
any suggestions welcome.
joncb
The reason I am asking is that I need to create a timer after a certain event (Collision). The collision actor is destroyed, however, there needs to be a dedicated timer associated with that particular collision event. Normally not an issue, however, there are clones of the collision actor, which can also have a collision event - spawning new timers, which may occur before the original timer expires.
I don't want to be limited to a prescribed number of collision actors, give them individual names then create a whole lot of timer events attached to the event actor; as for different levels in the game there is going to be a different number of collision actors.
The specific case is when a ball hits a specific actor, the ball shrinks (say to size 2) for a prescribed period of time - before it returns to its original size (size 1). If the ball collides with a clone of the collision actor before the fist timer expires, the ball will shrink further (to size 3) - initating a second time - and so on. Once the first time expires, the ball will grow back to size 2, and once the second time expires, the ball returns to size 1. This is in effect a recusrsive algorithm, which I am not sure gE can accomodate, so is there a work around?
My approach is to create a timer on the collision event with a specific name based on the number of the clone. When that time event occurs, grow the ball up to the next size (managed through a global variable), then destroy the timer. But I need to create a timer event handler for the timer of that specified name.
clear as mud??
any suggestions welcome.
joncb