Optimizing a fade out
Good morning all,
I have written a small snippet of code to show certain aspects of the minimap children, by controlling their alpha, when I mouseover the minimap. Further, when the mouse leaves the minimap, it starts a fadeout process that occurs relatively smoothly, 20 incremental decreases of alpha by 0.05 over 1 second. I couldn't think of a better way to code this, and everything works as intended. I am writing this to determine how to do it better. Thank you, I'm guessing this is way over engineered and am eager to learn more about how to do this more efficiently. Lua Code:
|
Normally I use the animation api for fadein/out animations.
https://github.com/zorker/rothui/blo...efader.lua#L55 Though for the minimap I do not do that. I just use an onleave delay timer of 1 second to hide all minimap icons. https://github.com/zorker/rothui/blo.../core.lua#L156 |
Hey zork,
Thanks for your reply. I based this on your code; however, I wanted to fade out rather than just immediately set the alpha to 0. I'll take a look at running animations. Thanks! |
I was able to dry code the following:
Lua Code:
Of note, I didn't understand why you need the onupdate and the onfinished functions. Why is that, exactly? |
Ended up having some bugs (naturally) and I wet coded it to:
Lua Code:
Works like a charm, it's a lot longer than my original code, but probably a tiny bit more efficient than doing a meta table look up 20 times. |
Looks good. :)
|
All times are GMT -6. The time now is 08:20 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI