JeZxLee Posted July 22, 2017 Share Posted July 22, 2017 Hi, How would I change the game's framerate from within JavaScript? Game will have 3 different speeds(game modes) Thanks! JeZxLee Quote Link to comment Share on other sites More sharing options...
xerver Posted July 22, 2017 Share Posted July 22, 2017 setTimeout(callback, ms) Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted July 22, 2017 Author Share Posted July 22, 2017 Ok, thanks! JeZxLee Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted July 22, 2017 Author Share Posted July 22, 2017 Hi, Having problems with modifying the framerate: <script> function gameLoop() { FrameCount++; requestAnimationFrame(gameLoop); state(); renderer.render(stage); } <!-- "A 110% By Team www.16BitSoft.com!" --> </script> if (GameMode == 0) setTimeout( gameLoop, (33) ); else if (GameMode == 1) setTimeout( gameLoop, (17) ); else if (GameMode == 2) setTimeout( gameLoop, (11) ); What I do wrong? JeZxLee Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted July 22, 2017 Author Share Posted July 22, 2017 Ok, I got it working, thanks! JeZxLee Quote Link to comment Share on other sites More sharing options...
xerver Posted July 22, 2017 Share Posted July 22, 2017 You use setTimeout instead of requestAnimationFrame, not in addition to. 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.