Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
cerulean

Best practice(s) for modifying running Timeline(Max) (UPDATED)

Recommended Posts

UPDATE:

The question below is still valid — but in the end I'm going to be playing parts of an already established timeline (as detailed in another post) so I believe that simply stopping the main timeline and playing my other one and continuing the main one is the best option, unless there's a way to insert a section of a timeline into another timeline

 

I have a game that runs by playing one grand timeline from start to finish.

The variations in game play occur by simply updating some individual tweens if the players hits a target, etc — the main timeline keeps running.

I've just been informed that sometimes though something else should happen — a very complex series of things perfectly suited for another timeline.

What would be the best way to do this?

1) Pause the main timeline and set up and play my subsidiary timeline?

-- OR --

2) Create my subsidiary timeline and simply insert it into the main one at the current time?

"2" seems more elegant to me as I don't have to start/stop the maintimeline and also listen for when the second timeline ends, but I'm not sure how it would work. Could I just (pseudo code)

mainTimeline.insert(newTimeline,mainTimeline.currentTime)
?
Link to comment
Share on other sites

Either option should work fine, and here's the code for option 2 (assumes you're using v12): 

mainTimeline.add(newTimeline, mainTimeline.time());

The nice (or bad, depending on your objectives) thing about #2 is that if you reverse() the main timeline or seek() later on, it'll still have the newTimeline in there, thus rendering things accordingly. If the newTimeline is more of a "one-and-done" thing, it'd probably be better to just handle it separately. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×