Originally Posted by Atropos
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!
|
A while back acies sent this information:
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:
ZO_AlphaAnimation:New(animatedControl)
ZO_AlphaAnimation:GetControl()
ZO_AlphaAnimation:FadeIn(delay, duration, fadeOption, callback, shownOption)
ZO_AlphaAnimation:FadeOut(delay, duration, fadeOption, callback, shownOption)
ZO_AlphaAnimation:PingPong(initialAlpha, finalAlpha, duration, loopCount, callback)
ZO_AlphaAnimation:SetPlaybackLoopsRemaining(loopCount)
ZO_AlphaAnimation:IsPlaying()
ZO_AlphaAnimation:SetMinMaxAlpha(minAlpha, maxAlpha)
ZO_AlphaAnimation:Stop(stopOption)
Code:
Arguments:
delay, duration - milliseconds
fadeOption - ZO_ALPHA_ANIMATION_OPTION_USE_CURRENT_ALPHA or ZO_ALPHA_ANIMATION_OPTION_FORCE_ALPHA
callback - function which will be called when animation finishes
showOption - ZO_ALPHA_ANIMATION_OPTION_USE_CURRENT_SHOWN or ZO_ALPHA_ANIMATION_OPTION_FORCE_SHOWN
stopOption - ZO_ALPHA_ANIMATION_OPTION_PREVENT_CALLBACK or nil
A small example:
Lua Code:
local tlw, texture, animation
local function OnMouseUp(self, button, upInside)
local currentAlpha = control:GetAlpha()
local delay = 0 -- milliseconds before animation starts
local duration = 2000 -- milliseconds for full animation. Actual duration will be duration * currentAlpha.
local fadeOption = ZO_ALPHA_ANIMATION_OPTION_USE_CURRENT_ALPHA
local callback -- I will leave callback nil, it is function which will be called when animation finishes
local showOption = ZO_ALPHA_ANIMATION_OPTION_USE_CURRENT_SHOWN
if currentAlpha < 0.5 then
animation:FadeIn(delay, duration, fadeOption, callback, shownOption)
else
animation:FadeOut(delay, duration, fadeOption, callback, shownOption)
end
end
tlw = WINDOW_MANAGER:CreateTopLevelWindow()
tlw:SetDimensions(128,128)
tlw:SetAnchor(CENTER, GuiRoot, CENTER, 0, 0)
tlw:SetHandler("OnMouseUp", OnMouseUp)
tlw:SetMouseEnabled(true)
tlw:SetAlpha(1)
tlw:SetHidden(false)
texture = WINDOW_MANAGER:CreateControl(nil, tlw, CT_TEXTURE)
texture:SetTexture("/esoui/art/icons/poi/poi_groupboss_complete.dds")
texture:SetAnchorFill(tlw)
animation = ZO_AlphaAnimation:New(tlw)
(I didn't test this code, so there could be some typos)