How do I Limit FPS?

0 favourites
  • 6 posts
From the Asset Store
Create a game inspired by great arcade classics as Operation Wolf
  • Hi

    I want to limit the fps in my game so it only runs on a top of 30fps

    It's possible to do?

    It would be perfect because in the cutscenes everything runs to smoothly and i want a more cinematic aspect

    Thanks in advance!

  • You may want to look into Delta time in the manual it should give you the answers you need..

    hope that gets you started..

  • Delta time doesn't allow you to limit the frame rate though, it just makes it frame rate independent. Sometimes it's nice to limit the frame rate to 30 FPS as the fluctuations can be a bit jarring.

    Only way I've figured out how to do this is to run all the "every tick" conditions as "every 0.033 seconds". You also wouldn't be able to use a lot of behaviours since they are automatically frame rate independent, so you'd have to manually recreate any behaviours that you used with "every 0.033 seconds" too.

    I'd too would be interested to know if there was a simpler way to limit framrate.

  • You can't. It's been asked starting 4 years ago. And here is why.

    C2 uses an JS call called "requestAnimationFrame" from the browser. The browser is the final gatekeeper renderer and will never render above 60fps. Also the browser only ever renders based on the moniter/hardware syncing.

    C2 internal game loop was not written from the ground up to render cleanly at 30fps. Ashley tried to do a quick version. It didn't work out so well. For a proper controller FPS rendering would require a large re-write to the game loop. Stacked with the fact that Ashley doesn't believe that it's worth it there will never be controller FPS rendering.

    The only option is to let the game render at 60fps and instead control your logic to 30fps. Infact due to Ashley going over the technical reasons why C2 can't have controller FPS. I've been pushing for an advanced model of logic updates to use 30FPS.

    Truth is logic doesn't need to be updated 60fps. you can do 30fps logic updates and still play silky smooth. The benefit of this is that if the FPS drops below 50fps then you never notice. Ashley makes claims other wise that even at below 50fps games run smoothly. This is not true, but doesn't matter.

    So here are yoru options than asking for FPS controll.

    use Len suggested Every 0.033 tick. And stick all your logic into a new logic kernel. This is your best option.

    Your other option is to use R0j0Hounds Canvas plugin.

    Make 1 visible layer with Canvas. Make 1 visible layer for HUD(SpriteFonts dont render on Canvas).

    All other layers on invisible. If C2 has no changes to show then C2 won't render the scene.

    Every 0.033 tick. Make all other layers visible. Then render all layers to canvas. Turn all layers back to invisible(except HUD and Canvas).

    This will result in your 30fps rendering.

  • A couple notes - you can also use system compare > tickcount%2 = 0 to run logic every other tick, that might be a bit more stable than every x seconds.

    Also instead of rendering everything to a canvas, you might be able to turn 'clear background' to off instead and get the same effect for far less CPU resources. If you still want to paste to a canvas though, use the paster plugin instead of the canvas plugin as it also supports webgl.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • That sounds like an option, I'm going to try soon, thank you!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)