mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
Fixed usage of pairs() where ordered iteration is needed.
http://www.esotericsoftware.com/forum/viewtopic.php?f=7&t=1660
This commit is contained in:
parent
c4bab94483
commit
e80a4c7085
@ -39,6 +39,7 @@ function AnimationState.new (data)
|
|||||||
local self = {
|
local self = {
|
||||||
data = data,
|
data = data,
|
||||||
tracks = {},
|
tracks = {},
|
||||||
|
trackCount = 0,
|
||||||
events = {},
|
events = {},
|
||||||
onStart = nil, onEnd = nil, onComplete = nil, onEvent = nil,
|
onStart = nil, onEnd = nil, onComplete = nil, onEvent = nil,
|
||||||
timeScale = 1
|
timeScale = 1
|
||||||
@ -60,6 +61,7 @@ function AnimationState.new (data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
self.tracks[index] = entry
|
self.tracks[index] = entry
|
||||||
|
self.trackCount = math.max(self.trackCount, index)
|
||||||
|
|
||||||
if entry.onStart then entry.onStart(index) end
|
if entry.onStart then entry.onStart(index) end
|
||||||
if self.onStart then self.onStart(index) end
|
if self.onStart then self.onStart(index) end
|
||||||
@ -67,7 +69,8 @@ function AnimationState.new (data)
|
|||||||
|
|
||||||
function self:update (delta)
|
function self:update (delta)
|
||||||
delta = delta * self.timeScale
|
delta = delta * self.timeScale
|
||||||
for i,current in pairs(self.tracks) do
|
for i = 0, self.trackCount do
|
||||||
|
local current = self.tracks[i]
|
||||||
if current then
|
if current then
|
||||||
local trackDelta = delta * current.timeScale
|
local trackDelta = delta * current.timeScale
|
||||||
current.time = current.time + trackDelta
|
current.time = current.time + trackDelta
|
||||||
@ -88,7 +91,8 @@ function AnimationState.new (data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function self:apply(skeleton)
|
function self:apply(skeleton)
|
||||||
for i,current in pairs(self.tracks) do
|
for i = 0, self.trackCount do
|
||||||
|
local current = self.tracks[i]
|
||||||
if current then
|
if current then
|
||||||
local time = current.time
|
local time = current.time
|
||||||
local lastTime = current.lastTime
|
local lastTime = current.lastTime
|
||||||
@ -145,6 +149,7 @@ function AnimationState.new (data)
|
|||||||
self.clearTrack(i)
|
self.clearTrack(i)
|
||||||
end
|
end
|
||||||
self.tracks = {}
|
self.tracks = {}
|
||||||
|
self.trackCount = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function self:clearTrack (trackIndex)
|
function self:clearTrack (trackIndex)
|
||||||
@ -155,6 +160,9 @@ function AnimationState.new (data)
|
|||||||
if self.onEnd then self.onEnd(trackIndex) end
|
if self.onEnd then self.onEnd(trackIndex) end
|
||||||
|
|
||||||
self.tracks[trackIndex] = nil
|
self.tracks[trackIndex] = nil
|
||||||
|
if trackIndex == self.trackCount - 1 then
|
||||||
|
self.trackCount = self.trackCount - 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function self:setAnimationByName (trackIndex, animationName, loop)
|
function self:setAnimationByName (trackIndex, animationName, loop)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user