Oh I see... That's pretty amazing :P
I still think though that using sin every quarter of a second isn't NEARLY as efficient then multiplying by -1. And I see the disadvantage of my function, it uses SetAlpha WAAAAAAAAAY too often. This should be much much more efficient.
Code:
frame.mult = 1
frame.alpha = 1
frame.tslu = 0 -- time since last update
frame:SetScript("OnUpdate", function(self, elapsed)
self.tslu = self.tslu + elapsed
if self.tslu > .25 then
self.tslu = 0
self:SetAlpha(self.alpha)
end
self.alpha = self.alpha - elapsed*self.mult
if self.alpha < 0 and self.mult > 0 then
self.mult = self.mult*-1
self.alpha = 0
elseif self.alpha > 1 and self.mult < 0 then
self.mult = self.mult*-1
end
end)
Final question, is it efficienter to use solution #1 or #2? I can hardly imagine that mod is faster then setting a variable to a table, but I may be wrong since frames have metatables etc etc etc...
#1
Code:
self.tslu = self.tslu + elapsed
if self.tslu > .25 then
self.tslu = 0
self:SetAlpha(self.alpha)
end
#2
Code:
self.tslu = self.tslu + elapsed
if self.tslu%.25 < .125 then
self:SetAlpha(self.alpha)
end