Limit FPS down to 60fps

0 favourites
  • 12 posts
From the Asset Store
Create a game inspired by great arcade classics as Operation Wolf
  • I'm having serious issues with sound sync because of fps and it's variation.

    Well, I'll handle the sound sync later, but to start the solution, C2 can handle the limit of FPS?

    Why of it? I'm running the project on a laptop, where it show average 60fps, but on my gaming computer, it's near of 200fps, the animation finished 3 times before the music..

    Yes, I'm using .dt for everything, and maybe time scaling it would work, but I don't want go this way at this time.

    Do you know any magic to keep the frame rate at 60fps or less?

  • I thought C2 limited the FPS TO 60! Even if the FPS was at 200, dt should correct for it. This sounds like a bug.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can check it? The animation link

  • I think you'll have to share a bit of capx for this one.

    If you're moving your sprite properly, fps shouldn't interfere with how long your animation is.

    For instance, if you want to move a sprite 100px to the right in 3seconds

    You should do something like:

    Every tick -> Sprite: set X to self.X+100/3*dt

    As dt is the time (in second) between the last and the current frame, no matter how much fps you have, after 3 secondes things should add up to 100.

  • Yann,

    This issue is about animation.

    The Delta time was used to animate because if I play the animation normally, it will never sync with the music (because of the pure fact every computer in the world will have a frame rate different).

    I just want cap the frame rate to 60 or above.

    Doing this way, setting the animation frame to occur on the dt, instead of fps or tick, to maintain it sync with the music.

  • Animation speed automatically uses dt, I am pretty sure. A higher framerate should not impact it. My bet is that there is a problem with the music - it could be taking longer-shorter to load.

    Also, I thought C2 capped the framerate to 60. Any word on this, Ashley?

  • It's not C2 that caps the framerate, it's the browser which does it. Which browser are you testing in? Almost every browser I can think of caps the framerate to 60 FPS, except Safari for iOS due to a missing feature in the browser (I think it will cap to 60 FPS from iOS 6). So it's weird if it goes above 60 FPS, it shouldn't be possible.

    Your demo wavers around 50-80 FPS at the start for me, but once the game starts it's a steady 60 FPS. I think there's a little quirk at work here: if the screen has not changed, C2 doesn't bother redrawing the screen (it's a waste of battery on mobile devices). Presumably the intro animation is only running at 10-20 FPS, so C2 will only be redrawing at that rate. However not drawing anything seems to throw off Chrome's Vsync a little and occasionally the FPS goes over 60 if the screen is only occasionally redrawing. It shouldn't matter because dt works for any framerate, higher or lower than 60. So again it's weird this affects you. But you could try putting a text object offscreen and always setting its text to tickcount which will force a redraw every tick.

    (I hope that's not a Sprite object with lots of frames - that will use a huge amount of memory!)

  • You can try timing how long the animation takes to run and see if it's exact. Say you have 3000 frames with a animation speed of 60. If it's exact it should take 50 seconds.

    If it is not exact you could set the animation speed to 0 and manually calculate which frame to use with events.

    start of layout:

    -> play music

    time <= 50

    -> set animation frame to int(time*60)

  • You can try timing how long the animation takes to run and see if it's exact. Say you have 3000 frames with a animation speed of 60. If it's exact it should take 50 seconds.

    If it is not exact you could set the animation speed to 0 and manually calculate which frame to use with events.

    start of layout:

    -> play music

    time <= 50

    -> set animation frame to int(time*60)

    I did it this way:

    *First canvas:

    **Pre-load the music;

    *Second Canvas:

    ** Set the animation frame by frame using dt to don't delay, 15ms per frame;

    On the laptop, the music finish exactly when the spaceship hit his second point, it was calculated to be this way.

    On the computer, the animation run very fast.. I'll re-install Chrome to see if it still affecting, because of yours reports.

  • Have you updated your graphics card drivers?

    <img src="smileys/smiley36.gif" border="0" align="middle" />

    It's a great way to sound clever about a problem when I don't know how to solve it ;)

  • everyday, ^^

    I'm very compulsive with the best performance of my equipment.

    Solved, was something weird with the chrome.

    Thanks everybody who take a time to help here!

  • I made a game a time ago that if there wasn't anything running every tick then the fps would go to 200+, everything go super fast.. but it was on a old version of Construct2(8x or 9x I guess)..

    so the reason for that could be on your events ;)

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