public class Clock
extends java.lang.Object
Game
to emit simulation update and
frame paint signals. Note: these values are exposed as public mutable fields for
efficiency. Clients should naturally not mutate these values, only the clock provider.Modifier and Type | Field and Description |
---|---|
float |
alpha
If this clock is used by a game with separate simulation and paint schedules, this value
represents the fraction of time between the last simulation update and the next scheduled
update.
|
int |
dt
The number of milliseconds that have elapsed since the last signal.
|
int |
tick
The number of milliseconds that have elapsed since time 0.
|
Constructor and Description |
---|
Clock() |
public int tick
public int dt
public float alpha
For example if the previous update was scheduled to happen at T=500ms and the next update at T=530ms and the actual time at which we are being rendered is T=517ms then alpha will be (517-500)/(530-500) or 17/30. This is usually between 0 and 1, but if your game is running slowly, it can exceed 1. For example, if an update is scheduled to happen at T=500ms and the update actually happens at T=517ms, and the update call itself takes 20ms, the alpha value passed to paint will be (537-500)/(530-500) or 37/30.
Copyright © 2019. All Rights Reserved.