How do I Limit FPS?

Get help using Construct 2

Post » Sat May 31, 2014 1:01 am

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!
B
15
S
3
G
3
Posts: 37
Reputation: 3,627

Post » Sat May 31, 2014 3:54 pm

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

https://www.scirra.com/tutorials/67/delta-time-and-framerate-independence

hope that gets you started..
When in doubt..or you are lost in a Zombie apocalypse or someone is giving you a hard time..Remember one thing..... Read the Construct 2 Manual..it will save your life.:)
B
35
S
13
G
8
Posts: 318
Reputation: 7,685

Post » Sat May 31, 2014 5:04 pm

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.
B
7
S
2
G
1
Posts: 37
Reputation: 1,278

Post » Sat May 31, 2014 6:09 pm

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.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,018

Post » Sat May 31, 2014 6:52 pm

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.
Moderator
B
94
S
33
G
33
Posts: 3,006
Reputation: 27,749

Post » Mon Jun 02, 2014 4:35 am

That sounds like an option, I'm going to try soon, thank you!
B
15
S
3
G
3
Posts: 37
Reputation: 3,627


Return to How do I....?

Who is online

Users browsing this forum: marcinkowski, plinkie, zenox98 and 25 guests