Jump to content
Search Community

Running code onUpdate callback

Michael71 test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hello,

 

I'm making a small 2D game and using (naturally) GSAP for the animation engine. So I'm Tweening a bullet by x,y and onUpdate I'm running collision detection to see if the bullet collides with any objects.

 

However as the objects on the DOM increase onUpdate seems to be "skipping" some frames thus "lagging".

 

Is there a better way to run somewhat complex code with TweenMax/Min? Maybe by listening on ticker? Or is onUpdate using requestAnimationFrame already?

 

Thanks in advance!

 

 

Link to comment
Share on other sites

Yes, the entire engine's pulse is driven by requestAnimationFrame by default. That means onUpdate is driven likewise.

 

I can assure you that the engine isn't "skipping" any frames (well, at least I can't imagine how that could possibly happen unless the browser itself isn't dispatching a requestAnimationFrame when it's updating the screen).  

 

It sounds like maybe you're just pushing too many graphics around the screen (or the graphics are large) and the browser's graphics rendering engine is having a tough time drawing all the pixels fast enough (which is unrelated to GSAP). 

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...