Step

This function will update the time with an elasped time of 1/60. This will cause the application speed and UPS to behave as though the application is running at exactly 60 frame per second, regardless of the real frame rate.

Syntax

Remarks

Whereas Leadwerks::Time::Update will handle framerates that fall below 60 hz and interpolate between physics frames smoothly, Leadwerks::Time::Step makes the application run at a constant logical framerate. If the framerate is faster than 60 hz, this function will make a call to Time;:Delay() to slow it down. The only problem arises if the framerate falls below 60 hz. In that case, the logical frame rate will still run at a constant speed and the application will appear slower. For this reason, it is recommended the user call Leadwerks::Time::Update() in most cases instead.

Example

--Create a window
window = Window:Create()
context = Context:Create(window)
world = World:Create()
local camera = Camera:Create()
camera:Move(0,0,-3)
local light = DirectionalLight:Create()
light:SetRotation(35,35,0)

model = Model:Box()
model:SetColor(0.0,0.0,1.0)

while true do

if window:Closed() or window:KeyHit(Key.Escape) then return false end

--Press the space key pause and resume timing
if (window:KeyHit(Key.Space)) then

paused = not paused
if (paused) then

Time:Pause()

else

Time:Resume()
end
end


model:Turn(0,Time:GetSpeed(),0)

Time:Update()
world:Update()
world:Render()

context:SetBlendMode(Blend.Alpha)
context:DrawText("Time: "..Time:GetCurrent(),2,2)
context:DrawText("Millisecs: "..Time:Millisecs(),2,22)

context:Sync()

end