-
Notifications
You must be signed in to change notification settings - Fork 78
(API) Progressbar
The progress bar object functions like a normal progress bar. The progress bar object can lerp and perform a function when it reaches it's maximum value.
local frame = loveframes.Create("frame")
frame:SetName("Progress Bar")
frame:SetSize(500, 160)
frame:CenterWithinArea(unpack(demo.centerarea))
local progressbar = loveframes.Create("progressbar", frame)
progressbar:SetPos(5, 30)
progressbar:SetWidth(490)
progressbar:SetLerpRate(10)
local button1 = loveframes.Create("button", frame)
button1:SetPos(5, 60)
button1:SetWidth(490)
button1:SetText("Change bar value")
button1.OnClick = function(object2, x, y)
progressbar:SetValue(math.random(progressbar:GetMin(), progressbar:GetMax()))
end
local button2 = loveframes.Create("button", frame)
button2:SetPos(5, 90)
button2:SetWidth(490)
button2:SetText("Toggle bar lerp")
button2.OnClick = function(object2, x, y)
if progressbar:GetLerp() == true then
progressbar:SetLerp(false)
else
progressbar:SetLerp(true)
end
end
local slider = loveframes.Create("slider", frame)
slider:SetPos(5, 135)
slider:SetWidth(490)
slider:SetText("Progressbar lerp rate")
slider:SetMinMax(0, 50)
slider:SetDecimals(0)
slider:SetValue(10)
slider.OnValueChanged = function(object2, value)
progressbar:SetLerpRate(value)
end
local text1 = loveframes.Create("text", frame)
text1:SetPos(5, 120)
text1:SetText("Lerp Rate")
text1:SetFont(love.graphics.newFont(10))
local text2 = loveframes.Create("text", frame)
text2:SetFont(love.graphics.newFont(10))
text2.Update = function(object, dt)
object:SetPos(slider:GetWidth() - object:GetWidth(), 120)
object:SetText(slider:GetValue())
end
Called when the object reaches it's maximum value
Arguments passed: self [object]
local progressbar = loveframes.Create("progressbar")
progressbar.OnComplete = function(object)
print("Complete!")
end
Sets the object's maximum value
object:SetMax(max[number])
Gets the object's maximum value
Returns 1 value: max [number]
local max = object:GetMax()
Sets the object's minimum value
object:SetMin(min[number])
Gets the object's minimum value
Returns 1 value: min [number]
local min = object:GetMin()
Sets the object's minimum and maximum values
object:SetMinMax(min[number], max[number])
Gets the object's minimum and maximum values
Returns 2 values: minimum [number], maximum [number]
local min, max = object:GetMinMax(min[number], max[number])
Sets the object's value
object:SetValue(value[number])
Gets the object's value
Returns 1 value: value [number]
local value = object:GetValue()
Sets whether the object should lerp or not
object:SetLerp(lerp[boolean])
Gets whether the object should lerp or not
Returns 1 value: lerp [boolean]
local lerp = object:GetLerp()
Sets the rate at which the object should lerp
object:SetLerpRate(lerp[number])
Gets the rate at which the object should lerp
Returns 1 value: lerprate [number]
local lerprate = object:GetLerpRate()
Gets whether or not the object has reached it's maximum value
Returns 1 value: completed [boolean]
local completed = object:GetCompleted()
Gets the object's bar width
Returns 1 value: bar width [number]
local completed = object:GetCompleted()