Gerente Posted March 10, 2018 Share Posted March 10, 2018 What is the difference between PIXI.ticker.shared.elapsedMS and the deltaTime in ticker.add(function (deltaTime) { renderer.render(stage); }); The elapsedMS returns 6.94444444444 the deltaTime returns 0.416666666 I don't see the relation. Thanks Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 10, 2018 Share Posted March 10, 2018 Consier we have 60FPS and everything is fine, then deltaTime=1. If we have lags and 30FPS as result, in that case deltaTime is 2. If you want to move the object 5 pixels per frame, then use "5 * deltaTime" xwz86 1 Quote Link to comment Share on other sites More sharing options...
Gerente Posted March 10, 2018 Author Share Posted March 10, 2018 Thanks, I understand that, but shouldnt elapsedMS do the same thing? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 11, 2018 Share Posted March 11, 2018 Its the same thing, but in milliseconds. If you want "300 pixels per second" you use "0.3 * elapsedMs" , and if you want "5 pixels per frame" you use "5 * deltaTime" Quote Link to comment Share on other sites More sharing options...
PsichiX Posted March 11, 2018 Share Posted March 11, 2018 not 5 pixels per frame (that way it would be just 5) Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 11, 2018 Share Posted March 11, 2018 35 minutes ago, PsichiX said: not 5 pixels per frame (that way it would be just 5) That's why its useful - if you dont know how to make animation smooth - just multiply whatever you want by deltaTime. Quote Link to comment Share on other sites More sharing options...
Gerente Posted March 11, 2018 Author Share Posted March 11, 2018 please read my post, they have different values. maybe there is a bug. Mostly when I'm in another tab and then I come back Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 12, 2018 Share Posted March 12, 2018 > Mostly when I'm in another tab and then I come back Not a bug. Read the ticker sources: https://github.com/pixijs/pixi.js/blob/dev/src/core/ticker/Ticker.js#L40 > The elapsedMS returns 6.94444444444 > the deltaTime returns 0.416666666 0.42 = 7 * 60 / 1000 Quote Link to comment Share on other sites More sharing options...
Gerente Posted March 12, 2018 Author Share Posted March 12, 2018 Ooooh, that's why, elapsedMS is in seconds (even if the name says MS) and deltaTime in miliseconds. As always, thanks IVAN! Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 12, 2018 Share Posted March 12, 2018 its in milliseconds. deltaTime is in frames, if you want TARGET_FPMS. By default its 1/60 of second. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.