Jump to content
GreenSock

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

Running code onUpdate callback

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