Start the animation for n_loops, replacing the static texture

By default, if n_loops is not set, the animation plays once. If n_loops == -1.0 then the animation loops infinitely. Otherwise, the animation repeats, e.g. it repeats twice and a half if n_loops == 2.5.

The animation can be stopped using animate_stop.

Property definitions

gamnit $ Sprite :: animate
	# Start the `animation` for `n_loops`, replacing the static `texture`
	#
	# By default, if `n_loops` is not set, the animation plays once.
	# If `n_loops == -1.0` then the animation loops infinitely.
	# Otherwise, the animation repeats, e.g. it repeats twice and a half
	# if `n_loops == 2.5`.
	#
	# The animation can be stopped using `animate_stop`.
	fun animate(animation: Animation, n_loops: nullable Float)
	do
		if not animation.valid then print_error "{class_name}::animate: invalid animation {animation}"

		var shader_animation = shader_animation
		if shader_animation == null or animation.frames.first.root != shader_animation.frames.first.root then
			# Resort with the new animation texture
			needs_remap
		else
			needs_update
		end

		var sprite_set = sprite_set
		animation_start = if sprite_set != null then sprite_set.time else -1.0
		animation_loops = n_loops or else 1.0
		self.shader_animation = animation
		self.animation = animation
	end
lib/gamnit/flat/flat_core.nit:120,2--145,4