Animation Tutorial Request
Hey folks, I'd like to put a bounty out for a simple tutorial on using the ESO AnimationManager and/or AnimationObjects. If anyone is familiar with these functions, I would love to see a brief code snippet that explains the how to instantiate an animation object, associate it with a control, and fire the animation.
For example, maybe a quick how-to on transitioning the alpha of control from 0 to 1 over a 2 second duration? This would be really helpful if anyone understands it enough to share some tricks! |
Quote:
http://www.esoui.com/forums/showthread.php?t=1191 I use a simple alpha animation in Bloody Screen addon, but I do not use AnimationManager directly, I'm using ZO_AlphaAnimation object. Lua Code:
Code:
Arguments: Lua Code:
|
You are in luck as this is exactly what I did yesterday. :D
I tried to make a small addon that allows my actionbar to fade to 20% instead of completely vanishing from screen when I set it to automatic in the settings. First we need to create a timeline. This can either be done in lua or xml, but I personally think xml might bit a bit more readable for animations. Code:
<GuiXml> Next step is to instantiate this timeline. We also need to get a reference to the alpha animation as we want to set the alpha values in lua so we can add a settings panel in the future. Code:
local startAlpha, endAlpha = 0.2, 0.8 -- we also set it to 80% transparency so it is see through when it is active The actionbar already uses a fade animation and calls SetHidden once it has finished fading out. So in order to get this animation to work there are some things we have to do:
Replacing the animation is not hard. The action bar uses a ZO_HUDFadeSceneFragment which has a method GetAnimation that returns self.animation, so all we have to do is set the animation field and apply the animation to the control element. Code:
ACTION_BAR_FRAGMENT.animation = animation The ZO_HUDFadeSceneFragment calls SetHidden in two places ACTION_BAR_FRAGMENT.animationReverseOnStop and ACTION_BAR_FRAGMENT.Show. We simply replace animationReverseOnStop with a custom method: Code:
local hidden = true -- we use this to replace the logic of SetHidden, otherwise the action bar will behave weirdly Code:
ZO_PreHook(ACTION_BAR_FRAGMENT, "Show", function(self, customShowDuration) Code:
control:SetHidden(false) To fix this we add a callback to scenemanager and listen for the hud changing its state: Code:
local hud = SCENE_MANAGER:GetScene("hud") -- default hud scene As you can see from this example, animations are quite simple to use.
Warning: Spoiler
|
Thank you both very much, extremely helpful!
|
All times are GMT -6. The time now is 09:49 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI