gamnit :: Animation :: defaultinit
# Animation for sprites, set with `Sprite.animate`
#
# Two main services create animations:
# * The constructors accepts an array of textures and the number of frames per
# seconds: `new Animation(array_of_subtextures, 10.0)`
# * The method `Texture::to_animation` uses the whole texture
# dividing it in frames either on X or Y:
# `new Texture("path/in/assets.png").to_animation(30.0, 0, 12)`
class Animation
# Frames composing this animation
#
# All frames must share the same `Texture::root`, be on a vertical or
# horizontal line, be spaced equally and share the same dimensions.
var frames: SequenceRead[Texture]
# Frames per seconds, a higher value makes this animation faster
#
# The animation speed is also affected by `SpriteSet::time_mod`.
var fps: Float
# Are the `frames` valid for an animation? (see the requirements in `frames`)
var valid: Bool is lazy do
var r: nullable RootTexture = null
for f in frames do
if r == null then
r = f.root
else
if r != f.root then return false
end
end
# TODO check for line, constant distance, and same aspect ratio.
return true
end
end
lib/gamnit/flat/flat_core.nit:321,1--357,3