Jump to content
Search Community

gsap.ticker.add() - Does the add function on the to the ticker create a new instance?

Parrot Puppet test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hey GSAP!

 

I have a question regarding the ticker function and if the add() function of the ticker will add it to the list of functions it will tick through or if it starting a new global timeline / instance of the ticker?

In the example below I created a scene with two classes. The first class I have a render loop using the gsap.ticker and another class that passes the gsap.ticker and uses the add() function for another render loop. In this case are bother the squares rendering in the same tick or am I creating another ticker when it may not be necessary?

Example: https://jsfiddle.net/mr_parrott/x21dnhbk/28/

 

Thanks for your time!

Link to comment
Share on other sites

  • Solution
4 minutes ago, mr-parrott said:

I have a question regarding the ticker function and if the add() function of the ticker will add it to the list of functions it will tick through or if it starting a new global timeline / instance of the ticker?

No, it doesn't create a new global timeline or a new instance of a ticker. There's only ONE global timeline, and only ONE ticker. Period. When you add() a listener/callback to the ticker, it just ensures that the function gets called as soon as the global timeline is done rendering on each tick. So if you're trying to do some rendering on a canvas or something, there's no point in having multiple functions do that.

 

Does that clear things up?

  • Like 1
  • Thanks 1
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...