deltatiming.ui.lua
txt = UI.Text.Create();
txt:Set({
font = UI.FONT.MEDIUM,
width = 200,
height = 50,
r = 255,
g = 255,
b = 255,
a = 255,
x = UI.ScreenSize().width / 2,
y = UI.ScreenSize().height / 2
});
txt2 = UI.Text.Create();
txt2:Set({
font = UI.FONT.MEDIUM,
width = 200,
height = 50,
r = 255,
g = 255,
b = 255,
a = 255,
x = UI.ScreenSize().width / 2,
y = UI.ScreenSize().height / 1.5
});
local MAX_VALUE = 255; local DURATION = 3;
local start, current = UI.GetTime(),0;
function UI.Event:OnUpdate()
local time = UI.GetTime();
local delta = UI.GetDeltaTime();
txt:Set( {text = "Delta: " .. tostring( delta )} );
if current < MAX_VALUE then
local addValue = MAX_VALUE / DURATION;
current = current + ( addValue * delta );
end
if current >= MAX_VALUE then
txt2:Set( {text = "Finish time: " .. tostring( (time - start) )} );
start = time;
current = 0;
end
end