I'm attempting to create a smooth health bar animation for a personal project. The goal is to eventually make it as smooth as possible, smoothing over the jumps when you do get health back. If that makes sense. Here is what I have at the moment:
Lua Code:
function Animate_SetWidth(self, changeWidthTo)
-- Make sure we have a timeline & animation.
if ( not self.animation ) then
self.timeline = ANIMATION_MANAGER:CreateTimeline();
self.animation = self.timeline:InsertAnimation(ANIMATION_SIZE, self);
end
local width = self:GetWidth();
local height = self:GetHeight();
self.animation:SetStartAndEndWidth(width, changeWidthTo)
self.animation:SetStartAndEndHeight(height, height)
self.animation:SetDuration(500)
self.animation:SetEasingFunction(ZO_EaseOutQuadratic)
self.timeline:PlayFromStart()
end
So that brings me to my questions:
- Is this the best way to achieve what I want?
- And is there a way to stop it from the start-stop animation when regaining health/magicka/stamina?
EDIT: Changing the duration to 2 seconds makes it a little less jerky but makes it seem much slower.
EDIT2: Is possible to animate a statusbar rather then creating a blank control and adding on a backdrop?