Use elapsed time for energy tick animation
This commit is contained in:
@@ -57,25 +57,28 @@ module.enable = function(self)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local pheight, pwidth = PlayerFrameManaBar:GetHeight(), PlayerFrameManaBar:GetWidth()
|
local pheight, pwidth = PlayerFrameManaBar:GetHeight(), PlayerFrameManaBar:GetWidth()
|
||||||
energytick:SetScript("OnUpdate", function()
|
energytick:SetScript("OnUpdate", function()
|
||||||
if this.target then
|
if this.target then
|
||||||
this.start, this.max = GetTime(), this.target
|
this.max = this.target
|
||||||
this.target = nil
|
this.current = 0
|
||||||
end
|
this.target = nil
|
||||||
|
end
|
||||||
|
|
||||||
if not this.start then return end
|
if not this.max then return end
|
||||||
|
|
||||||
this.current = GetTime() - this.start
|
-- OnUpdate already provides the exact elapsed frame time. Accumulating arg1
|
||||||
|
-- keeps the spark just as smooth without querying GetTime() every frame.
|
||||||
|
this.current = (this.current or 0) + arg1
|
||||||
|
|
||||||
if this.current > this.max then
|
if this.current > this.max then
|
||||||
this.start, this.max, this.current = GetTime(), 2, 0
|
this.max, this.current = 2, 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos = (pwidth ~= "-1" and pwidth or width) * (this.current / this.max)
|
local pos = (pwidth ~= "-1" and pwidth or width) * (this.current / this.max)
|
||||||
if not pheight then return end
|
if not pheight then return end
|
||||||
this.spark:SetPoint("LEFT", pos-((pheight+5)/2), 0)
|
this.spark:SetPoint("LEFT", pos-((pheight+5)/2), 0)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
energytick.spark = energytick:CreateTexture(nil, 'OVERLAY')
|
energytick.spark = energytick:CreateTexture(nil, 'OVERLAY')
|
||||||
energytick.spark:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark")
|
energytick.spark:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark")
|
||||||
|
|||||||
Reference in New Issue
Block a user