-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLibTranslateAnimation.lua
More file actions
38 lines (31 loc) · 1.17 KB
/
Copy pathLibTranslateAnimation.lua
File metadata and controls
38 lines (31 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
LibTranslateAnimation = ZO_Object:Subclass()
function LibTranslateAnimation:New( ... )
local result = ZO_Object.New( self )
result:Initialize( ... )
return result
end
function LibTranslateAnimation:Initialize( control )
self.control = control
self.timeline = ANIMATION_MANAGER:CreateTimeline()
end
--- Translate Position
-- @tparam number x
-- @tparam number y
-- @tparam number duration
function LibTranslateAnimation:TranslateTo( from_x, from_y, to_x, to_y, duration, anchorIndex )
local animation = nil
if ( self.timeline:IsPlaying() ) then
animation = self.timeline:GetFirstAnimation()
else
animation = self.timeline:InsertAnimation( ANIMATION_TRANSLATE, self.control ) --CreateSimpleAnimation( ANIMATION_TRANSLATE, control )
end
animation:SetDuration( duration or 1 )
animation:SetEasingFunction( ZO_EaseInQuadratic )
animation:SetStartOffsetX( from_x )
animation:SetStartOffsetY( from_y )
animation:SetEndOffsetX( to_x )
animation:SetEndOffsetY( to_y )
animation:SetAnchorIndex( anchorIndex )
self.timeline:SetPlaybackType( ANIMATION_PLAYBACK_ONE_SHOT, 0 )
self.timeline:PlayFromStart()
end