Jump to content

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

TweenLite.ticker current delta time

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

Hey guys,

I'm using TweenLite's ticker to provide my game with a loop I can use for updating the physics.

To make my game framerate independent I need the delta time (DT).


The docs suggest the callback receives event which I thought might include the DT, however the event is undefined.


I can calculate the delta time myself however I was hoping it would be available.


For now I can do this...

var previous_time = 0,
    dt = 0;

TweenLite.ticker.addEventListener("tick", function() {
    previous_time = current_time
    current_time = TweenLite.ticker.time
    dt = (current_time - previous_time) * 1000
Link to comment
Share on other sites

Yep, it's best if you calculate it rather than us injecting code into the core that'd carry with it a cost [albeit small] for everyone, especially because I'd bet that less than 0.001% of users would ever use it. Doesn't hurt to ask, though :) If a lot of people start requesting it, we'll reconsider. 

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.