How To Repeat Timeline Moments! [SOLVED]

D

Diamond Hunter Zero

Guest
This is a call out for assistance on how to effectively repeatedly execute moments within a single timeline within GML.

As part of a game I'm working on, I want to employ a cut-scene mechanic where distinct stages of cut-scenes are all written as a sequence of timeline moments. This means that each moment within these timelines contains a bunch of code doing stuff such as drawing and changing variables which work together to produce a single stage within the cut-scene sequence. It's intended to work like this:

An object called Obj_cutscene initializes a timeline like this:
Code:
var_timer = 0;
timeline_id = cutscene_timeline
timeline_running = true;
timeline_speed = 1;
And in it's step event, runs this code:
Code:
if(var_timer  > 90)
    {timeline_position += 1;
     timeline_speed = 0;
     var_timer = 0}
else
    {var_timer += 1}
Meanwhile, each moment/step in cutscene_timeline looks something like this:
Code:
//run some surface drawing events
//draw more shapes and text here
//move a object to x,y
// etc ......

timeline_speed = 0;
There is a moment for every step in the timeline (step 0,1,2,3 ...) all corresponding to stages 0,1,2,3 ... and so on in the cut-scene.


The problem is that Gamemaker only executes each moment in the timeline ONCE (as expected...). I need Obj_cutscene to repeatedly execute each moment of the timeline as if it were in a step event, until the timer completes and it moves on to the next stage/moment. Otherwise, the various text, sprites, and shapes drawn exist only for a single frame.

I don't want to hard-code these cutscene stages into the draw event of the object itself, since there would be simply to many variables and if-statements to worry about.

So I'm asking, is there a way to make an object repeatedly execute a specific moment in a timeline every single step, Or is there another way of performing this staged drawing mechanic?

Capture1.PNG
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Simply set the timeline_index variable back to the position in the timeline to loop from. :)

EDIT: Alternatively, set the timeline speed to 1, and then check the index and when it reaches the moment you want to repeat then subtract 1 from the timeline index every step that the timer runs (don't change the speed)... this should also make the same moment repeat.
 
D

Diamond Hunter Zero

Guest
Simply set the timeline_index variable back to the position in the timeline to loop from. :)

EDIT: Alternatively, set the timeline speed to 1, and then check the index and when it reaches the moment you want to repeat then subtract 1 from the timeline index every step that the timer runs (don't change the speed)... this should also make the same moment repeat.
Thanks for pointing out a clever (and embarrassingly simple) solution! :D I couldn't find anywhere that suggested this method!
 
Top