Jump to content
Search Community

best way to run 2 gsap.timelines run at the same time?

Dcoo test
Moderator Tag

Recommended Posts

Im not sure of the best way to run 2 gsap.timelines run at the same time?

I don't get an error but my second gsap.timeline ( var animation_mob = new gsap.timeline ) will not load.  it more then likely its my naming of the second timelines variables  is causing the problem. but maybe you can't run 2. timelines with 2 canvas ?  any feed back would be greatly appreciated! 

cheers!

See the Pen GRjyzyb by davicoo (@davicoo) on CodePen

Link to comment
Share on other sites

Hey Dcoo. Again, you've got a lot going on in your demo. Please strip out everything that's not related to your question if you'd like our help debugging. Often times it's best to recreate the situation that you're asking about from the ground up just using some colored rectangles. Often times you'll be able to figure out the issue yourself by doing so.

  • Like 1
Link to comment
Share on other sites

2 hours ago, Dcoo said:

but maybe you can't run 2. timelines with 2 canvas ?

Absolutely you can. Run as many tweens and/or timelines as you want - GSAP doesn't have any limits in that regard. 

 

I saw one problem right away - do NOT use the "new" keyword: 

// BAD
var animation_mob = new gsap.timeline({..});

// GOOD 
var animation_mob = gsap.timeline({..});

It looks like you're using the old GSAP 2 syntax too. It's fine, it works, but the newer GSAP 3 syntax is more concise, readable, and convenient in my opinion. Like use strings for your eases and set the duration in the vars object instead of the 2nd parameter.

 

If you open the console, you'll see a ton of errors about drawImage() being called on something that's not being given the proper type. You're trying to feed in a value like sprite_mob.textures_mob[sprite.frame] but your Array is empty. That's done twice in your demo. Totally unrelated to GSAP. Like Zach said, if you need more help please provide a minimal demo and we'd be glad to look at it. 

 

Happy tweening!

  • Like 2
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.
×
×
  • Create New...