forked from martinjlowm/AnimationGroup
-
Notifications
You must be signed in to change notification settings - Fork 0
Animation SetSmoothProgress
LaYt edited this page Oct 4, 2022
·
3 revisions
Sets the smooth progress for an animation.
Animation:SetSmoothProgress(smoothProgress)
smoothProgress - Progress of the animation: between 0.0 (at start) and 1.0 (at end) (number)

-- Create a Button with a significant bounce effect.
local frame = SetSmoothProgressExample or CreateFrame('button', "SetSmoothProgressExample", UIParent)
frame:ClearAllPoints()
frame:SetPoint("CENTER", 300, 0)
frame:SetWidth(200)
frame:SetHeight(100)
frame.bg = frame:CreateTexture()
frame.bg:SetTexture(0,0,0,1)
frame.bg:SetAllPoints()
frame:EnableMouse(true)
frame:RegisterForClicks("LeftButtonUp")
local function smoothing(self)
local p = self:GetSmoothProgress()
local c = p^p
self:SetSmoothProgress(c)
end
SetSmoothProgressExample.animationGroup = SetSmoothProgressExample:CreateAnimationGroup()
local scale = SetSmoothProgressExample.animationGroup:CreateAnimation("Scale")
scale:SetFromScale(0,0)
scale:SetToScale(1,1)
scale:SetDuration(1)
scale:SetScript("OnUpdate", smoothing)
SetSmoothProgressExample:SetScript("OnClick", function()
this.animationGroup:Play()
end)