crystal.AnimatedSprite
A Drawable component that can draw animations from a Spritesheet.
Constructor
Like all other components, AnimatedSprite components are created by calling Entity:add_component.
The constructor for AnimatedSprite expects one argument, the Spritesheet to play animations from.
Methods
| Name | Description |
|---|---|
| play_animation | Plays an animation from its beginning. |
| set_animation | Plays an animation, not restarting if it’s already playing. |
| update_sprite_animation | Updates the current animation frame drawn by this component. |
Examples
local ecs = crystal.ECS:new();
local entity = ecs:spawn(crystal.Entity);
entity:add_component(crystal.AnimatedSprite, crystal.assets.get("assets/hero.json"));
entity:play_animation("idle");