vrelisean Posted October 12, 2021 Share Posted October 12, 2021 I'm trying to make an object rotate constantly, with the speed of 3°/sec (360° in 2 minutes). The code should be pretty simple: let object; function setup() { ... object = new PIXI.Sprite(...); app.ticker.add(delta => renderLoop(delta)); } function renderLoop(delta) { object.angle += 3 / 60; } On every render, I increase object's angle by 3 divided by 60 (amount of times the renderLoop function will be called per second). However, when using stopwatch the rotation happens quicker than 3°/sec, and after playing with numbers I concluded that the approximate (if not fully correct) number is 144, and not 60. What can be the cause of this, and is there a better way to get that number instead of hardcoding it? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 12, 2021 Share Posted October 12, 2021 * Math.PI / 180.0 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 12, 2021 Share Posted October 12, 2021 (edited) Oh wait, angle is already in degrees. The problem is that your monitor has 144Hz , and to take that into account you have to do "3 / 60 * delta" Edited October 12, 2021 by ivan.popelyshev vrelisean 1 Quote Link to comment Share on other sites More sharing options...
vrelisean Posted October 12, 2021 Author Share Posted October 12, 2021 12 hours ago, ivan.popelyshev said: Oh wait, angle is already in degrees. The problem is that your monitor has 144Hz , and to take that into account you have to do "3 / 60 * delta" Works, thank you! 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.