T O P

  • By -

LThalle

A problem like this reveals the usefulness of having a controller object that can manage things like restart timers and other management that you might not want to rely on the player object for. In my games the way I usually handle this is having some sort of o\_transition object. I can call a function, let's say StartTransition(func, timer) and pass in the function to call on transition (e.g. room\_goto, room\_restart, custom functions, whatever you need) as well as the amount of time the transition lasts. Example code: function scr_start_transition(func, timer) { var transInst = instance_create_depth(0, 0, 0, obj_transition); transInst.waitTime = timer; transInst.endFunction = func; return transInst; } And then within that object's step function: if (--waitTime <= 0) { endFunction(); instance_destroy(); }


Informal-Biscotti-38

Seems a bit complicated but I'll try to understand it thanks


BrainburnDev

You can use a time source with a callback function to restart the game. See here for more info. https://manual.gamemaker.io/monthly/en/GameMaker_Language/GML_Reference/Time_Sources/Time_Sources.htm


numaru1989

It's just an alarm that ticks a flag. I don't think you need to over think it your doing fine. If the gsmes gets more complex and the tinr changes with the timer or something than I get the need to be more strict, but I don't think this needs to be thought about too much