diff --git a/spine-lua/Animation.lua b/spine-lua/Animation.lua index cd1287280..37f0e3801 100644 --- a/spine-lua/Animation.lua +++ b/spine-lua/Animation.lua @@ -50,8 +50,17 @@ function Animation.new (name, timelines, duration) local self = { name = name, timelines = timelines, + timelineIds = {}, duration = duration } + + for i,timeline in ipairs(self.timelines) do + self.timelineIds[timeline:getPropertyId()] = true + end + + function self:hasTimeline(id) + return self.timelineIds[id] == true + end function self:apply (skeleton, lastTime, time, loop, events, alpha, blend, direction) if not skeleton then error("skeleton cannot be nil.", 2) end diff --git a/spine-lua/AnimationState.lua b/spine-lua/AnimationState.lua index 7e5b8ae86..aeec135b2 100644 --- a/spine-lua/AnimationState.lua +++ b/spine-lua/AnimationState.lua @@ -894,13 +894,13 @@ function AnimationState:computeHold(entry) if to == nil or timeline.type == Animation.TimelineType.attachment or timeline.type == Animation.TimelineType.drawOrder or timeline.type == Animation.TimelineType.event - or not self:hasTimeline(to, id) then + or not to.animation:hasTimeline(id) then timelineMode[i] = FIRST else local next = to.mixingTo skip = false while next do - if not self:hasTimeline(id) then + if not next.animation:hasTimeline(id) then if entry.mixDuration > 0 then timelineMode[i] = HOLD_MIX timelineHoldMix[i] = next @@ -917,14 +917,6 @@ function AnimationState:computeHold(entry) end end -function AnimationState:hasTimeline(entry, id) - local timelines = entry.animation.timelines - for i,timeline in ipairs(timelines) do - if timeline:getPropertyId() == id then return true end - end - return false -end - function AnimationState:getCurrent (trackIndex) return self.tracks[trackIndex] end