fix: add fallback for animations
This commit is contained in:
parent
7993e6b6fe
commit
84e48c0320
1 changed files with 10 additions and 1 deletions
|
@ -87,9 +87,18 @@ function Animator:changeAnimation(name, restart)
|
||||||
restart = restart or false
|
restart = restart or false
|
||||||
end
|
end
|
||||||
|
|
||||||
self.currentAnimation = name
|
if (self.sprite.data.animations[name] ~= nil) then
|
||||||
|
self.currentAnimation = name
|
||||||
|
else
|
||||||
|
self.currentAnimation = self.sprite.data.metadata.defaultAnim
|
||||||
|
end
|
||||||
|
|
||||||
self.animationData = self.sprite.data.animations[self.currentAnimation]
|
self.animationData = self.sprite.data.animations[self.currentAnimation]
|
||||||
|
|
||||||
|
if (self.animationData == nil) then
|
||||||
|
error("animation " .. self.currentAnimation .. " not found.")
|
||||||
|
end
|
||||||
|
|
||||||
if (restart == true) then
|
if (restart == true) then
|
||||||
self.frame = self.animationData.startAt
|
self.frame = self.animationData.startAt
|
||||||
self.frameTimer = 0
|
self.frameTimer = 0
|
||||||
|
|
Loading…
Reference in a new issue