Merge pull request #57 from moitias/luaanimationfixes

Fix a few Lua animation problems
This commit is contained in:
Nathan Sweet 2013-06-03 03:49:25 -07:00
commit 5f903865f7

View File

@ -36,7 +36,7 @@ function Animation.new (name, timelines, duration)
function self:apply (skeleton, time, loop) function self:apply (skeleton, time, loop)
if not skeleton then error("skeleton cannot be nil.", 2) end if not skeleton then error("skeleton cannot be nil.", 2) end
if loop and duration then time = time % duration end if loop and duration > 0 then time = time % duration end
for i,timeline in ipairs(self.timelines) do for i,timeline in ipairs(self.timelines) do
timeline:apply(skeleton, time, 1) timeline:apply(skeleton, time, 1)
@ -46,7 +46,7 @@ function Animation.new (name, timelines, duration)
function self:mix (skeleton, time, loop, alpha) function self:mix (skeleton, time, loop, alpha)
if not skeleton then error("skeleton cannot be nil.", 2) end if not skeleton then error("skeleton cannot be nil.", 2) end
if loop and duration then time = time % duration end if loop and duration > 0 then time = time % duration end
for i,timeline in ipairs(self.timelines) do for i,timeline in ipairs(self.timelines) do
timeline:apply(skeleton, time, alpha) timeline:apply(skeleton, time, alpha)
@ -372,7 +372,7 @@ function Animation.ColorTimeline.new ()
local b = lastFrameB + (frames[frameIndex + FRAME_B] - lastFrameB) * percent local b = lastFrameB + (frames[frameIndex + FRAME_B] - lastFrameB) * percent
local a = lastFrameA + (frames[frameIndex + FRAME_A] - lastFrameA) * percent local a = lastFrameA + (frames[frameIndex + FRAME_A] - lastFrameA) * percent
if alpha < 1 then if alpha < 1 then
slot:setColor(slot.r + (r - color.r) * alpha, slot.g + (g - color.g) * alpha, slot.b + (b - color.b) * alpha, slot.a + (a - color.a) * alpha) slot:setColor(slot.r + (r - slot.r) * alpha, slot.g + (g - slot.g) * alpha, slot.b + (b - slot.b) * alpha, slot.a + (a - slot.a) * alpha)
else else
slot:setColor(r, g, b, a) slot:setColor(r, g, b, a)
end end