animations now have a flag for when they update their img frame
This commit is contained in:
parent
918c63c535
commit
6ba4f4d1c9
@ -10,6 +10,8 @@ function Animation:new(anim_data,speed)
|
||||
o.frame = 1
|
||||
o.speed = speed or 1
|
||||
|
||||
o.was_updated = false
|
||||
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
return o
|
||||
@ -49,6 +51,9 @@ end
|
||||
|
||||
-- to linearly animate
|
||||
function Animation:animate()
|
||||
if self.was_updated then
|
||||
self.was_updated = false
|
||||
end
|
||||
if self.frames[self.frame] ~= 0 then
|
||||
-- try to animate
|
||||
self.subframe = self.subframe + self.speed
|
||||
@ -56,6 +61,7 @@ function Animation:animate()
|
||||
if self.subframe > self.frames[self.frame]*game.framerate then
|
||||
self.subframe = self.subframe - self.frames[self.frame]*game.framerate
|
||||
self.frame = self.frame + 1
|
||||
self.was_updated = true
|
||||
end
|
||||
|
||||
-- cycle
|
||||
|
Loading…
Reference in New Issue
Block a user