View Single Post
02-06-10, 08:42 AM   #26
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
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
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote