Nov 12, 2011

I have the power to control time!

Here is a little useful tidbit for GM users: Even when a time line isn't running, it's still running! It's a useful little feature in how GM handles timelines that also works with the instance_destroy() function. Once a step in a timeline is executed, all events in that step get processed before the timeline is stopped, even if you add timeline_running = false at the start of the step.

So say you did what I did and have the following script in a Step event

if !timeline_running
{
     instance_deactivate_object(prt_enemy)
}

And at the last step of the timeline you have

instance_activate_all(); 
instance_destroy()

There's a problem - the timeline is still running, so enemies are still deactivated even though the instance is destroyed. That's because timeline_running=false is processed after the Step event and instance_destroy() is processed near the very end (obviously the Destroy event is processed last). But you can instead use

timeline_running=false;
instance_activate_all();
instance_destroy();

And this will work just fine.

No comments:

Post a Comment

©TheouAegis Productions™. Powered by Blogger.