• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows Pausing Timelines

S

squidsRockets

Guest
I am trying to create a simple tower defence game using timelines to control the waves. I would like to stop the timeline at the end of each round and on user input, resume. I have tried multiple ways to do this but I can't get anything to work.
So far I have tried creating an object that sets timeline_running = false (and alternatively timeline_speed = 0) and when the user hits a key, it sets timeline to running (speed to 1) adds 1 to wave and destroys that object. I have also tried stopping from within the timeline by checking if there are enemies remaining.
I have gotten 2 different results. It either does stop correctly but then never resumes, or doesn't stop at all.
Any help is appreciated, this is very frustrating.
 
S

squidsRockets

Guest
I am trying to create a simple tower defence game using timelines to control the waves. I would like to stop the timeline at the end of each round and on user input, resume. I have tried multiple ways to do this but I can't get anything to work.
So far I have tried creating an object that sets timeline_running = false (and alternatively timeline_speed = 0) and when the user hits a key, it sets timeline to running (speed to 1) adds 1 to wave and destroys that object. I have also tried stopping from within the timeline by checking if there are enemies remaining.
I have gotten 2 different results. It either does stop correctly but then never resumes, or doesn't stop at all.
Any help is appreciated, this is very frustrating.
I have now tried pausing within the timeline and unpausing through a created object.
Code:
timeline_speed = 0;
timeline_running = false;

instance_create(x,y,oHalt);
In oHalt
Code:
if keyboard_check_pressed(vk_control)
{
   timeline_running = true;
   timeline_speed = 1;
   Wave += 1
   instance_destroy();
}
It does stop correctly but upon resuming, no more object spawn and it just adds 2 to Wave (I have this running twice in my timeline for a total of 3 waves)
I get one wave. then no more enemies and a skip to wave 3, but nothing happens
 

Fabseven

Member
I am at work right now so i donot have the code of my current project witch is using timeline as well
But i have no problem stopping it so i will check the code and tell you how i do it (this evening maybe)
 
H

Hephep

Guest
I had a similar issue with my project because I wanted to halt cutscene and wait for input, and the best I've got so far is that I have a timeline manager object, using a script "start timeline" you give it the name of the timeline to launch and launch it, and then you can stop the timeline with TLManager.timeline_running = false from another object then do TLManager.timeline_running = true when you need it.

If I remember well I had to create dedicated moment in the timeline for my pause, for example at time x the timeline execute a code that instanciate a "waitForInput" object that pause the current running timeline in it's create event, and then when I press a key it set the timeline to running again but I'm pretty sure any lines of code of this dedicated moment supposed to be executed after the pause is skipped.

Code:
//pausing my tl and waiting for input
instance_create(0,0, oWaitforinput);
//after this line, every line will be skipped and the timeline will run to the next moment

Also the key here is to keep in mind that timeline is not an object, but associated to an object, and as far as I know only one timeline can be launched by an object at a time. I find it very annoying. I am at work but will try to provide source code.
 
Last edited by a moderator:

Fabseven

Member
Hello, my code to start
Code:
  timeline_index = global.tlatk
    timeline_running = true
    timeline_speed = 1    
    timeline_position =  0
ok good...
to stop the timeline : well nothing i my project , i think the timeline continue until i create a new one (i have made a wave system) but in end my wave this way :

Code:
if( ds_list_empty(global.lst_atkmonster) )
{
    if(timeline_position >= timeline_max_moment( global.tlatk )  )
    {
        system_depop_heros()
        system_view_follow_mouse()
        system_next_day()
   
    }

}
"when there is not more monster and the timeline is finished then END"
 

TheouAegis

Member
I haven't tested it because it's an idea that just popped into my head, but what if when pausing or whatever you just did

with all timeline_running = -timeline_running;

0 becomes -0 which is still 0, and 1 becomes -1, which should be treated as boolean false in most cases. Does timeline_running treat -1 as a boolean false? If so, then this method would prevent you from starting any timelines that weren't already running before.
 
Top