How do I destroy an enemy after a delay
Warning: New User
I have a collision detection event between my Player and an Object which plays a sound, adds to the score, and destroys the second object.
How do I actually change the image of the second object, wait 1 second, and then do the destroy event? I can't seem to find a way to make the events work synchronously. This is a major concept I have not been able to figure out.
Your help is appreciated.
Re: How do I destroy an enemy after a delay
If you change the Disappearing animation, you can just have it be the image you want for a second. The Disappearing animation is played for you when you destroy the object, just as the Appearing animation is played when you create it.
Re: How do I destroy an enemy after a delay
This is good and it worked , but what would I use if I wanted to chain a series of events together one after the other? Is there no way to do step 1, when step 1 finishes do step 2, etc.?
Re: How do I destroy an enemy after a delay
You could manually play the animation and when it is over do something else.
Re: How do I destroy an enemy after a delay
I'd use an alterable value - it gives you more flexibility.
eg. Give the object an alterable value called "Delay", with a default value of -1, and then say something like:
+ Player collides with Object
-> Object: Set Delay to 200
+ Always
-> Object: Subtract 1 from Delay
+ Object: Delay = 150
-> Do something...
+ Object: Delay = 100
-> Do something else...
+ Object: Delay = 0
-> Destroy Object
It's pretty easy to calculate exactly what values you need to use.
If your game's framerate is 50fps, a delay of 50 = 1 second. If an object has an animation speed of 50, each game frame will last 50% as long as each animation frame (ie. an "always" event will run twice in the time it takes an animation to change frame once).