Limit FPS down to 60fps

Get help using Construct 2

Post » Tue Aug 07, 2012 6:44 pm

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?
ImageImageImageImageImageImage
B
93
S
19
G
12
Posts: 1,192
Reputation: 18,301

Post » Tue Aug 07, 2012 7:01 pm

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.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Tue Aug 07, 2012 7:10 pm

You can check it? The animation link
ImageImageImageImageImageImage
B
93
S
19
G
12
Posts: 1,192
Reputation: 18,301

Post » Tue Aug 07, 2012 9:13 pm

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.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Aug 07, 2012 9:46 pm

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.
ImageImageImageImageImageImage
B
93
S
19
G
12
Posts: 1,192
Reputation: 18,301

Post » Tue Aug 07, 2012 9:58 pm

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?
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Tue Aug 07, 2012 10:18 pm

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!)
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Tue Aug 07, 2012 10:30 pm

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)
B
79
S
24
G
54
Posts: 4,738
Reputation: 40,739

Post » Tue Aug 07, 2012 11:01 pm

[QUOTE=R0J0hound] 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)[/QUOTE]

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.TELLES08082012-08-07 23:03:37
ImageImageImageImageImageImage
B
93
S
19
G
12
Posts: 1,192
Reputation: 18,301

Post » Tue Aug 07, 2012 11:04 pm

Have you updated your graphics card drivers?



It's a great way to sound clever about a problem when I don't know how to solve it ;)
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 21 guests