core/assets: force restart of animator when animation name have changed

This commit is contained in:
Kazhnuz 2019-03-04 12:33:13 +01:00
parent 38b0a732c5
commit f9b4adb3b7
1 changed files with 7 additions and 0 deletions

View File

@ -74,6 +74,13 @@ function Animator:draw(x, y, r, sx, sy, ox, oy, kx, ky)
end
function Animator:changeAnimation(name, restart)
-- Force restart if animation name is different
if (self.currentAnimation ~= name) then
restart = true
else
restart = restart or false
end
self.currentAnimation = name
self.animationData = self.sprite.data.animations[self.currentAnimation]