macro_rules! include_aseprite {
($v: vis mod $module: ident, $($aseprite_args: tt)*) => { ... };
}Expand description
Includes sprites found in the referenced aseprite files.
Can include multiple at once and optimises palettes of all included in the single call together. See Size for supported sizes.
This generates a module given by the first argument, you can control the visibility of the module using the normal means. The generated module exports each Tag in the aseprite file as a static, the static will be all caps and have spaces and dashes converted to underscores.
use agb::include_aseprite;
include_aseprite!(
mod sprites,
"examples/gfx/chicken.aseprite"
);
use sprites::{JUMP, WALK, IDLE};The tags from the aseprite file are included so you can refer to sprites by name in code. You should ensure tags are unique as this is not enforced by aseprite.
Including from the out directory is supported through the $OUT_DIR token.
use agb::include_aseprite;
include_aseprite!(
mod sprites,
"$OUT_DIR/generated_sprite.aseprite"
);You may pass multiple aseprite files in. This is particularly useful if you have multiple sprites with different sizes since aseprite files require that every frame has the same size.
use agb::include_aseprite;
include_aseprite!(
mod sprites,
"examples/gfx/crab.aseprite",
"examples/gfx/crab-small.aseprite"
);You can optionally specify a target sprite size before a file path to split
each frame into multiple smaller sprites. The size is given as WIDTHxHEIGHT
and must be a valid GBA sprite size. The frame dimensions must be evenly
divisible by the target size.
Sub-frames are generated in row-major order (left-to-right, top-to-bottom),
and tags are automatically adjusted to cover all sub-frames. Note that
Tag::animation_sprite and Tag::animation_frame will iterate over
individual sub-frames, not complete original frames. You will likely want
to use Tag::sprite directly to display all sub-frames for a given
original frame yourself.
use agb::include_aseprite;
include_aseprite!(
mod sprites,
32x16 "examples/gfx/big_character.aseprite",
"examples/gfx/small_item.aseprite"
);