"Pulsating" effect...what's the proper method?
I have frame "frame". I want it to fade from alpha "1" to alpha "0", then back to alpha "1" and repeat until I say otherwise to make a "pulsing" effect.
I tried doing this in a manner like so, and...well...yeah, infinite loops are bad. lua Code:
Hello, Mr. Client Crash. :o |
Code:
local SHINE_FADE_IN = 0.15; |
Well did a quick search and there isn't much around on that subject so perhaps they hit a wall.
So far all I have seen is people utilising it on Enter and Leave scripts to do the different Fading functions. So how about this. If you have an Update function that you call every so often perhaps you can put it in there to fadein if it has faded out or to fade out if it has faded in. Then keep a variable to store the last value updated. It's not perfect but might be the only way you can deal with it and even throwing the cycle in every event you watch may be a good idea too. The combination of the two functions may be enough to make it look passable at least. Edit: Or what d87 said :D |
Pretty elegant IMO:
lua Code:
|
*book marks post so I can come back and ste... erm I mean utilise the code* :D
Quote:
|
You'll want to hide the frame doing the OnUpdate when it's done, else you'll be needlessly using CPU.
|
Quote:
|
Quote:
(Also bookmarking as a reference page) |
Quote:
lua Code:
|
Quote:
Quote:
|
Quote:
FINAL VERSION(I hope): lua Code:
|
Quote:
Anyway: Saying "it's using so little CPU" and then ignoring that is rather dismissive - people running 200+ AddOns which do this are suddenly using a metric ****-ton of CPU for no reason whatsoever. If you aren't currently generating a pulse, the frame should be hidden so its OnUpdate will not be run. |
Quote:
Quote:
**EDIT: Just discovered something while we're on the topic of performance that I thought should be part of this: You can set this thing to absolutely ridiculous speeds (I've personally tried it up to 150, WELL beyond my refresh rate, just to see what would happen). The only upper limit here is your computers' crash threshold. BE CAREFUL WHEN DOING THIS. The reason it was/is using so little CPU is because apparently Blizz uses GPU time for this. On my machine at 1440x900, Ultra settings w/ some cVar tweaks, fullscreen windowed, and a frame pulsing at 150, I hit around 50%-ish GPU usage on average (peak no higher than 65%) with dual 5700-series ATis. At any "normal" speed (say, 0.3 to 10.0 at the fastest) it's negligible, though. I'm also pulsing a pretty big frame (1024x256). Really, if you need something faster than 10...don't. You're gonna give kids seizures. |
Check blackbox (http://wow.curseforge.com/addons/blackboxlua/)
You may want to look at the animation system. Blizzard uses this kind of stuff for the Glyph window. http://wowprogramming.com/utils/xmlb...rd_GlyphUI.lua Look out for "PulseGlow". The cool stuff is that you can "PLAY" and "STOP" those animations as you wish. I cannot recommend onUpdate stuff anymore, the animations are much more valuable imo since they eat nearly no cpu usage instead of those nasty onupdates. I'm using the animation system for rFrameRotater. Since you can "LOOP" animations it will start and never stop. (If you say so.) Very simple rotate-function that I'm using to rotate stuff. Code:
function a:rotateme(texture,width,height,scale,anchorframe,framelevel,texr,texg,texb,alpha,duration,side,blendmode,point,pointx,pointy) So sth. like this could be it, don't know the exact syntax http://wowprogramming.com/docs/widgets/Alpha/SetChange Code:
local h = CreateFrame("Frame",nil,UIParent) With the animation system you can do this in just one animationgroup. - move (translate) - rotate - scale - change alpha You can even add a path the frame will move on. |
Cool, I was wondering the use for animation barring prettifying movement around the screen. But if it's the better option than onUpdate it may be the way to go.
|
I'm not sure about how it would work in lua, but any pulsating effect can be achieved with a simple sinus function.
pseudo code: var sequence = 0; sequence ++; AlphaProperty = sin(sequence); this would result in the AlphaProperty going from 0 to 1, then from 1 to 0 and so on. google 'math sin lua' for more info :) Good luck |
http://www.wowwiki.com/API_UIFrameFlash
UIFrameFlash(frame, fadeInTime, fadeOutTime, flashDuration, showWhenDone, flashInHoldTime, flashOutHoldTime) if you call it more than once(while it's active) - you'll need something that blocks this calls: (atleast for UIFrameFadeIn it makes it nearly go to infinite time - if called unnecessary times (even if you use :GetAlpha()) - you would need something like spareTime=totaltime-(GetAlpha()/totaltime)) (Note this is for UIFrameFadeIn, and not UIFrameFlash) Code:
local fade_in = {} (Note inTable returns boolean,index of value in table(numeric)) dunno if you can 'calculate' the Pulse-time or want to fix it to some number |
Quote:
|
Quote:
Code:
do |
Quote:
Code:
last_update = last_update -0.25 |
All times are GMT -6. The time now is 12:30 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI