Skip to contents

Retrieves the current frame from a sprite animation.

Usage

render.animate(spritename, timer, sprites, render_framerate = 60)

Arguments

spritename

String; name of sprite as defined in sprites.

timer

Number of ticks elapsed since the animation started.

sprites

RAM$ROM$sprites; list of sprites.

render_framerate

RAM$ROM$framerate; game framerate.

Value

Returns a sprite matrix suitable for render.sprite().

Details

A sprite defined in ROM$sprites can either be simple or complex;

Simple sprites are just a static sprite matrix.

Complex sprites are a list containing multiple frames of animation. Complex sprites can have the following properties:

$framerate Framerate at which to play the animation.
$next_animationspritename of which animation from ROM$sprites to play next when all frames of this one have played. If NULL, animation loops.
$framesList of sprite matrices (simple sprites).
$offset.xOffsets the location at which the sprite is drawn; see render.object
$offset.yOffset relative to y.

Animated sprites can be tested using render.test_animation().

Examples

if (FALSE) { # \dontrun{
#simple two-part animation using sprite$next_animation
sprites = list(
bar.loading = list(
  framerate = 4, #frames per second
  next_animation = 'bar.complete', #will transition into this animation automatically
  frames = list(
    render.makesprite('
..........'),
    render.makesprite('
O.........'),
    render.makesprite('
OO........'),
    render.makesprite('
OOO.......'),
    render.makesprite('
OOOO......'),
    render.makesprite('
OOOOO.....'),
    render.makesprite('
OOOOOO....'),
    render.makesprite('
OOOOOOO...'),
    render.makesprite('
OOOOOOOO..'),
    render.makesprite('
OOOOOOOOO.'),
    render.makesprite('
OOOOOOOOOO')
  )
),
bar.complete = list(
  framerate = 2,
  frames = list(
    render.makesprite('
OOOOOOOOOO'),
    render.makesprite('
..........')
  )
)
)

render.test_animation('bar.loading',sprites)
} # }