GMR::Time
January 14, 2026 ยท View on GitHub
GMR Docs > Engine > Utilities > Time
GMR::Time
Frame timing and delta time access.
Table of Contents
Functions
delta
Get the time elapsed since the last frame in seconds. Use this for frame-independent movement and animation.
Returns: Float - Delta time in seconds
Example:
# Move at 100 pixels per second regardless of frame rate
player.x += 100 * GMR::Time.delta
elapsed
Get the total time elapsed since the game started in seconds.
Returns: Float - Total elapsed time in seconds
Example:
# Flash effect every 0.5 seconds
visible = (GMR::Time.elapsed % 1.0) < 0.5
fps
Get the current frames per second.
Returns: Integer - Current FPS
Example:
puts "FPS: #{GMR::Time.fps}"
set_target_fps
Set the target frame rate. The game will try to maintain this FPS. Set to 0 for unlimited frame rate.
Parameters:
| Name | Type | Description |
|---|---|---|
fps | Integer | Target frames per second |
Returns: Module - self for chaining
Example:
GMR::Time.set_target_fps(60) # Lock to 60 FPS
scale
Get the current time scale. Affects how fast game time passes. 1.0 = normal speed, 0.5 = half speed (slow motion), 0.0 = paused.
Returns: Float - Current time scale
Example:
current_scale = GMR::Time.scale
scale=
Set the time scale. Affects how fast game time passes. Timers created with scaled: true (default) will respect this. Set to 0.0 to pause, 0.5 for slow motion, 2.0 for fast forward.
Parameters:
| Name | Type | Description |
|---|---|---|
scale | Float | The new time scale (must be >= 0) |
Returns: Float - The new time scale
Example:
GMR::Time.scale = 1.0 # Normal speed
vsync=
Enable or disable vertical synchronization (VSync). When enabled, frame presentation waits for the display's vertical blank interval, eliminating screen tearing. When disabled, frames are presented immediately.
Parameters:
| Name | Type | Description |
|---|---|---|
enabled | Boolean | true to enable VSync, false to disable |
Returns: Boolean - The new VSync state
Example:
GMR::Window.vsync = false # Disable VSync for lower latency
vsync?
Check if vertical synchronization (VSync) is currently enabled.
Returns: Boolean - true if VSync is enabled, false otherwise
Example:
if GMR::Window.vsync?
puts "VSync is enabled"
end