mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[lua] Ported AnimationState changes
This commit is contained in:
parent
aca4060fad
commit
c0908f19ed
@ -247,11 +247,7 @@ function AnimationState:update (delta)
|
|||||||
end
|
end
|
||||||
skip = true
|
skip = true
|
||||||
end
|
end
|
||||||
if not skip then
|
|
||||||
self:updateMixingFrom(current, delta, true);
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
self:updateMixingFrom(current, delta, true)
|
|
||||||
-- Clear the track when there is no next entry, the track end time is reached, and there is no mixingFrom.
|
-- Clear the track when there is no next entry, the track end time is reached, and there is no mixingFrom.
|
||||||
if current.trackLast >= current.trackEnd and current.mixingFrom == nil then
|
if current.trackLast >= current.trackEnd and current.mixingFrom == nil then
|
||||||
tracks[i] = nil
|
tracks[i] = nil
|
||||||
@ -261,7 +257,10 @@ function AnimationState:update (delta)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not skip then current.trackTime = current.trackTime + currentDelta end
|
if not skip then
|
||||||
|
self:updateMixingFrom(current, delta)
|
||||||
|
current.trackTime = current.trackTime + currentDelta
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -269,28 +268,23 @@ function AnimationState:update (delta)
|
|||||||
queue:drain()
|
queue:drain()
|
||||||
end
|
end
|
||||||
|
|
||||||
function AnimationState:updateMixingFrom (entry, delta, canEnd)
|
function AnimationState:updateMixingFrom (entry, delta)
|
||||||
local from = entry.mixingFrom
|
local from = entry.mixingFrom
|
||||||
if from == nil then return end
|
if from == nil then return end
|
||||||
|
|
||||||
|
self:updateMixingFrom(from, delta)
|
||||||
|
|
||||||
local queue = self.queue
|
local queue = self.queue
|
||||||
if canEnd and entry.mixTime >= entry.mixDuration and entry.mixTime > 0 then
|
if entry.mixTime >= entry.mixDuration and from.mixingFrom == nil and entry.mixTime > 0 then
|
||||||
|
entry.mixingFrom = null
|
||||||
queue:_end(from)
|
queue:_end(from)
|
||||||
local newFrom = from.mixingFrom
|
return
|
||||||
entry.mixingFrom = newFrom
|
|
||||||
if newFrom == nil then return end
|
|
||||||
entry.mixTime = from.mixTime;
|
|
||||||
entry.mixDuration = from.mixDuration;
|
|
||||||
from = newFrom;
|
|
||||||
end
|
end
|
||||||
|
|
||||||
from.animationLast = from.nextAnimationLast
|
from.animationLast = from.nextAnimationLast
|
||||||
from.trackLast = from.nextTrackLast
|
from.trackLast = from.nextTrackLast
|
||||||
local mixingFromDelta = delta * from.timeScale
|
from.trackTime = from.trackTime + delta * from.timeScale;
|
||||||
from.trackTime = from.trackTime + mixingFromDelta;
|
entry.mixTime = entry.mixTime + delta * entry.timeScale;
|
||||||
entry.mixTime = entry.mixTime + mixingFromDelta;
|
|
||||||
|
|
||||||
self:updateMixingFrom(from, delta, canEnd and from.alpha == 1)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function AnimationState:apply (skeleton)
|
function AnimationState:apply (skeleton)
|
||||||
@ -305,7 +299,11 @@ function AnimationState:apply (skeleton)
|
|||||||
if not (current == nil or current.delay > 0) then
|
if not (current == nil or current.delay > 0) then
|
||||||
-- Apply mixing from entries first.
|
-- Apply mixing from entries first.
|
||||||
local mix = current.alpha
|
local mix = current.alpha
|
||||||
if current.mixingFrom then mix = mix * self:applyMixingFrom(current, skeleton) end
|
if current.mixingFrom then
|
||||||
|
mix = mix * self:applyMixingFrom(current, skeleton)
|
||||||
|
elseif current.trackTime >= current.trackEnd then
|
||||||
|
mix = 0
|
||||||
|
end
|
||||||
|
|
||||||
-- Apply current entry.
|
-- Apply current entry.
|
||||||
local animationLast = current.animationLast
|
local animationLast = current.animationLast
|
||||||
@ -563,11 +561,11 @@ function AnimationState:setAnimation (trackIndex, animation, loop)
|
|||||||
if current then
|
if current then
|
||||||
if current.nextTrackLast == -1 then
|
if current.nextTrackLast == -1 then
|
||||||
-- Don't mix from an entry that was never applied.
|
-- Don't mix from an entry that was never applied.
|
||||||
tracks[trackIndex] = nil
|
tracks[trackIndex] = current.mixingFrom
|
||||||
queue:interrupt(current)
|
queue:interrupt(current)
|
||||||
queue:_end(current)
|
queue:_end(current)
|
||||||
self:disposeNext(current)
|
self:disposeNext(current)
|
||||||
current = nil
|
current = current.mixingFrom
|
||||||
else
|
else
|
||||||
self:disposeNext(current)
|
self:disposeNext(current)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user