[−][src]Function ggez::timer::check_update_time
pub fn check_update_time(ctx: &mut Context, target_fps: u32) -> bool
Check whether or not the desired amount of time has elapsed since the last frame.
This function will return true if the time since the last
update()
call has been equal to or greater to the update FPS indicated by
the target_fps
. It keeps track of fractional frames, so if you
want 60 fps (16.67 ms/frame) and the game stutters so that there
is 40 ms between update()
calls, this will return true
twice
in a row even in the same frame, then taking into account the
residual 6.67 ms to catch up to the next frame before returning
true
again.
The intention is to for it to be called in a while loop
in your update()
callback:
fn update(&mut self, ctx: &mut Context) -> GameResult { while(timer::check_update_time(ctx, 60)) { update_game_physics()?; } Ok(()) }