Limit the fps

0 favourites
From the Asset Store
Create a game inspired by great arcade classics as Operation Wolf
  • Hello !

    My question can seem stupid, but in fact no lol.

    I have a game, for IOS, running at 60 fps, but sometimes, for no reason, it falls to 58 or 52.

    Even if it's great to stay above 30, my problem is that when I try it on my ipad (via CocoonJS launcher), when this little fall of FPS arrives, you can really notice it on the screen, i mean, you really see the fps fall. (the game "stops" for an half second or something)

    I don't know if it comes from Construct, my game or Cocoon, but i just don't want to see it.

    It's a shame, cause i'm always above 50, but you really notice it.

    So my question is : is it possible to set the max fps of a game, to avoid that ?

    and another question : if it's a cocoon laucher pb, will i have the same thing with the compilation ?

    Thanks !

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I get something similar when playing the games i'm working on. The framerate is solid for a while and then suddenly there's this "burp" for a second where everything freezes, and then it continues at high framerate. Usually only seems to occur once per play session, but it's a pretty nasty framerate drop when it happens. There's nothing in my code that should cause it from what I can see, and occurs even when exporting to executable. The executable is nailed at 60fps until this occurs, burps, and then back to 60fps.

  • Its hard to say what the problem is unless you post a video on what your working on, or maybe a playable demo (you don't have to post your capx file if you don't want to). It could be C2 itself or it could be one event you have somewhere in your source file thats causing something to go rigid or doing some additional processing that shouldn't be done, but once again I can't tell what kind of game your working on.

    Here's a guide that may help you with your performance:

    scirra.com/manual/134/performance-tips

  • Venivididormi I think this could be caused by a large texture being loaded or CPU intensive process, happening.

    Also consider other applications calling the system resources in the background...

    We need a

    "if framerate Burp" Condition .... <img src="smileys/smiley36.gif" border="0" align="middle" />

  • I had this issue too, i had no idea it decreased from 60 fps to 48 fps after of 5 minutes of playing.

    When i connected my iPod to recharge battery, it won't decrease fps during 20 minutes of playing.

  • I'm tested my game with Samsung Galaxy s2 and galaxy s3 via Cocoonjs by ludei, now i'm in the same trouble.

    My game running good in galaxy S2 with fps range 55-66 all the time, but with galaxy S3, after testing a few minutes, the fps drop to 38-4x fps and i really don't know why... I think galaxy s3 with powerfull hardware than s2 can run even smoothly.

    I'm tested 2 of my games, galaxy S2 work fine and game run on Galaxy S3 always drop FPS in a few minutes, from 6x to 4x. I try anythings i can to change my code and etc to fix the problem... But it's still happen. I'm about to release my game to google play.

  • Venivididormi I think this could be caused by a large texture being loaded or CPU intensive process, happening.

    I think it's a texture/asset being used for the first time. It seems to happen when the player is moving quickly into new parts of the map. But it's a little frustrating because i'm preloading and then even waiting a couple seconds before the player gets control and can see the world. Is there no "pre-cache everything, don't stream" type toggle somewhere? This is far after the layout loaded events have fired, so why would something already loaded into memory cause a burp when being used the first time? (Assuming we're correct at all lol)

  • I admit I am kinda pushing the engine a little, heh. Here's a screencap of the project with and without the realtime lighting enabled.

    <img src="http://img853.imageshack.us/img853/5995/lightingm.jpg" border="0" />

    However, notice i'm getting 60fps in both. In a browser it's between 35 and 40. So, the occasional single burp that goes from 60fps to zero and then back again within a second or two... odd.   :)

  • I don't know the problem come from construct or cocoonjs, trying many time to change my code and fix the problem about suddently drop fps, but failed.

  • I don't know the problem come from construct or cocoonjs, trying many time to change my code and fix the problem about suddently drop fps, but failed.

    I was just reading the manual some more and found that images and code are already loaded by the time layout loaded events etc have fired. I realised this might be related to sounds instead, since they're apparently loaded afterwards. I added an audio 'Preloads complete' condition to my level loader and the burp issues didn't occur when I tested it. It was just a quick test though so i'll report back if I see the issue again. Quite possible just a fluke it didn't occur.

  • I'll try that, hope it's work for me... I'll report back to you, too.

  • I still don't use sounds on my project, so it's not au audio pb i think.

    I have it on every device, even the Iphone5 (my game turns between 40 and 60 on an ipod 4).

    The more I think of it, the more I think it's a cocoonSJ pb, but i never succeed in using Appmobi, to try on it lol.

    Whatever, being able to define the fps limit would be very usefull to be sure to avoid this kind of problems.

  • It's probably Javascript garbage collection. We've worked hard to ensure the runtime doesn't create too many objects per tick, but occasionally it will do a full collect and that could make it skip a few frames. TBH for a garbage-collected language one "burp" every few minutes is a good result (badly done engines will be constantly choppy!), but I'm aware this is an issue. Hopefully Javascript engines will continue to improve and make collection faster and parallel (so it doesn't affect the framerate), and we'll keep GC optimising the engine to try and mitigate this.

    I'd also be wary of:

    • physics - avoid this *completely* if you want to avoid burps, because it creates huge amounts of garbage. It's difficult for us to fix because the physics engine itself does this.
    • third party plugins, which may not be GC optimised
    • creating and destroying large numbers of objects in events, since while C2 does recycle objects, this type of activity will probably flood the cache and end up creating garbage.

    If someone could send me their project to test, I could investigate possible sources of garbage creation and perhaps make optimisations for the next build.

  • I admit I am kinda pushing the engine a little, heh. Here's a screencap of the project with and without the realtime lighting enabled.

    <img src="http://img853.imageshack.us/img853/5995/lightingm.jpg" border="0" />

    However, notice i'm getting 60fps in both. In a browser it's between 35 and 40. So, the occasional single burp that goes from 60fps to zero and then back again within a second or two... odd.   :)

    Big fan of Terraria huh? Me too! Good taste!

    I too would like a way to limit FPS, but mine is purely because I'd like my project to feel like a retro game, and that's tough when the game runs smooth like a flash game.

  • Thanks Ashley !

    How can I send you my file ?

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