Closed mrspeaker closed 12 years ago
Ejecta uses CADisplayLink
to render frames in sync with the display's refresh rate, like all animations on the iPhone/iPad should. The iPhone's refresh rate is 60hz and thus Ejecta checks intervals and timeouts 60 times per second at most.
Trying to render an animation with 40fps on a 60hz display is generally a bad idea. It would render one frame, then skip the next display refresh, then render one frame, then skip two display refreshs, while the next frame would be rendered way to late; the animation would feel "jerky".
That's also the reason why console games are either "60hz" or "30hz" but never something in between. Rendering at constant 30fps looks way smoother than the stutter you'd get at 40fps.
CADisplayLink
works exactly like requestAnimationFrame
in the browser. It tries to be smart when scheduling frames - either running an animation at 60fps, or if that fails, drop down to 30fps.
So in short: don't do that. Just request an interval with 16ms or use requestAnimationFrame
and let the iPhone decide if it's fast enough for 60fps or not.
With all that said, I should probably reduce the check to interval < 0.017
, so you can run at 30fps if you really want to.
setInterval & setTimout now allow for 30fps. Everything below 18ms is still automatically scheduled for the next frame.
the game logic rate does not always equal to render rate。I think bind all loop to render rate is not a good way。
I was trying to run my game at a low FPS for my poor old 3Gs, but there seems to be some weirdness around the setTimeout timers:
If I remove this line from EJApp.m:
and ask for 40fps I get 30 on my iPhone and on the simulator. I need to slow the fps down a bit... is it safe to omit this check?
Thanks!