mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-07 11:16:53 +08:00
[lua] Fixed a bunch of issues in AnimationState
This commit is contained in:
parent
15ae8183f7
commit
7ae7372ae8
@ -69,7 +69,7 @@ function EventQueue:start (entry)
|
|||||||
local objects = self.objects
|
local objects = self.objects
|
||||||
table_insert(objects, EventType.start)
|
table_insert(objects, EventType.start)
|
||||||
table_insert(objects, entry)
|
table_insert(objects, entry)
|
||||||
animationState.animationsChanged = true
|
self.animationState.animationsChanged = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function EventQueue:interrupt (entry)
|
function EventQueue:interrupt (entry)
|
||||||
@ -82,7 +82,7 @@ function EventQueue:_end (entry)
|
|||||||
local objects = self.objects
|
local objects = self.objects
|
||||||
table_insert(objects, EventType._end)
|
table_insert(objects, EventType._end)
|
||||||
table_insert(objects, entry)
|
table_insert(objects, entry)
|
||||||
animationState.animationsChanged = true
|
self.animationState.animationsChanged = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function EventQueue:dispose (entry)
|
function EventQueue:dispose (entry)
|
||||||
@ -117,26 +117,26 @@ function EventQueue:drain ()
|
|||||||
local entry = objects[i + 1]
|
local entry = objects[i + 1]
|
||||||
if _type == EventType.start then
|
if _type == EventType.start then
|
||||||
if entry.onStart then entry.onStart(entry) end
|
if entry.onStart then entry.onStart(entry) end
|
||||||
if as.onStart then entry.onStart(entry) end
|
if as.onStart then as.onStart(entry) end
|
||||||
elseif _type == EventType.interrupt then
|
elseif _type == EventType.interrupt then
|
||||||
if entry.onInterrupt then entry.onInterrupt(entry) end
|
if entry.onInterrupt then entry.onInterrupt(entry) end
|
||||||
if as.onInterrupt then entry.onInterrupt(entry) end
|
if as.onInterrupt then as.onInterrupt(entry) end
|
||||||
elseif _type == EventType._end then
|
elseif _type == EventType._end then
|
||||||
if entry.onEnd then entry.onEnd(entry) end
|
if entry.onEnd then entry.onEnd(entry) end
|
||||||
if as.onEnd then entry.onEnd(entry) end
|
if as.onEnd then as.onEnd(entry) end
|
||||||
-- fall through in ref impl
|
-- fall through in ref impl
|
||||||
if entry.onDispose then entry.onDispose(entry) end
|
if entry.onDispose then entry.onDispose(entry) end
|
||||||
if as.onDispose then entry.onDispose(entry) end
|
if as.onDispose then as.onDispose(entry) end
|
||||||
elseif _type == EventType._dispose then
|
elseif _type == EventType._dispose then
|
||||||
if entry.onDispose then entry.onDispose(entry) end
|
if entry.onDispose then entry.onDispose(entry) end
|
||||||
if as.onDispose then entry.onDispose(entry) end
|
if as.onDispose then as.onDispose(entry) end
|
||||||
elseif _type == EventType.complete then
|
elseif _type == EventType.complete then
|
||||||
if entry.onComplete then entry.onComplete(entry) end
|
if entry.onComplete then entry.onComplete(entry) end
|
||||||
if as.onComplete then entry.onComplete(entry) end
|
if as.onComplete then as.onComplete(entry) end
|
||||||
elseif _type == EventType.event then
|
elseif _type == EventType.event then
|
||||||
local event = objects[i + 2]
|
local event = objects[i + 2]
|
||||||
if entry.onEvent then entry.onEvent(entry, event) end
|
if entry.onEvent then entry.onEvent(entry, event) end
|
||||||
if as.onEvent then entry.onEvent(entry, event) end
|
if as.onEvent then as.onEvent(entry, event) end
|
||||||
i = i + 1
|
i = i + 1
|
||||||
end
|
end
|
||||||
i = i + 2
|
i = i + 2
|
||||||
@ -173,12 +173,12 @@ function TrackEntry.new ()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function TrackEntry:getAnimationTime ()
|
function TrackEntry:getAnimationTime ()
|
||||||
if loop then
|
if self.loop then
|
||||||
local duration = animationEnd - animationStart
|
local duration = self.animationEnd - self.animationStart
|
||||||
if duration == 0 then return animationStart end
|
if duration == 0 then return self.animationStart end
|
||||||
return (trackTime % duration) + animationStart
|
return (self.trackTime % duration) + self.animationStart
|
||||||
end
|
end
|
||||||
return math_min(trackTime + animationStart, animationEnd)
|
return math_min(self.trackTime + self.animationStart, self.animationEnd)
|
||||||
end
|
end
|
||||||
|
|
||||||
local AnimationState = {}
|
local AnimationState = {}
|
||||||
@ -197,7 +197,7 @@ function AnimationState.new (data)
|
|||||||
animationsChanged = false,
|
animationsChanged = false,
|
||||||
timeScale = 1
|
timeScale = 1
|
||||||
}
|
}
|
||||||
queue = EventQueue.new(self)
|
self.queue = EventQueue.new(self)
|
||||||
setmetatable(self, AnimationState)
|
setmetatable(self, AnimationState)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -685,7 +685,7 @@ function AnimationState:disposeNext (entry)
|
|||||||
entry.next = nil
|
entry.next = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function AnimationState:animationsChanged ()
|
function AnimationState:_animationsChanged ()
|
||||||
self.animationsChanged = false;
|
self.animationsChanged = false;
|
||||||
|
|
||||||
self.propertyIDs = {}
|
self.propertyIDs = {}
|
||||||
@ -693,6 +693,7 @@ function AnimationState:animationsChanged ()
|
|||||||
|
|
||||||
-- need to get the highest index cause Lua is funny
|
-- need to get the highest index cause Lua is funny
|
||||||
local highest = -1
|
local highest = -1
|
||||||
|
local tracks = self.tracks
|
||||||
for i,entry in pairs(tracks) do
|
for i,entry in pairs(tracks) do
|
||||||
if i > highest then highest = i end
|
if i > highest then highest = i end
|
||||||
end
|
end
|
||||||
@ -700,7 +701,6 @@ function AnimationState:animationsChanged ()
|
|||||||
-- Set timelinesFirst for all entries, from lowest track to highest.
|
-- Set timelinesFirst for all entries, from lowest track to highest.
|
||||||
local i = 1
|
local i = 1
|
||||||
local n = highest
|
local n = highest
|
||||||
local tracks = self.tracks
|
|
||||||
while i <= n do
|
while i <= n do
|
||||||
local entry = tracks[i]
|
local entry = tracks[i]
|
||||||
if entry then
|
if entry then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user