View Single Post
02-06-10, 02:59 AM   #13
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by nightcracker View Post
<snip>So if you run at 120 FPS your calling a sin function 120 times per second.<snip>
Not true.

Code:
do
	local last_update = 0
	local updater = CreateFrame("Frame", nil, UIParent)

	updater:Hide()
	updater:SetScript("OnUpdate",
			  function(self, elapsed)
				  last_update = last_update + elapsed

				  if last_update >= 0.25 then
					  RunSinFunction()
					  last_update = 0
				  end
			  end)
end
That executes the sin function every quarter of a second.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote