β2.0.2 - SpriteTools? More like AnimationTools!
Pre-releaseSpriteTools Beta 2.0.2
Time to animate those sprites we made in the last version!
Make sure you read the ReadME before asking questions. Many of them are answered there.
How to Use
Extract the Source, copy everything into your project's respective folders (include goes to include, source goes to source), then you can start using any of the functions in this project in your own.
NOTE: SpriteTools currently have the following dependencies that must be installed: ctrulib, citro3d, sf2d (sf2d will eventually not be needed, but for now it is)
Attached is an example.zip
file as an example of how to use the debugging functions.
There will be a more detailed tutorial coming up in the future with an official release of 2.0 on the wiki.
New Features
Sprite Rendering
There was a thing or two we missed last time, so let's add them now:
ST_RenderSpriteAdvanced(st_frame *frame, int x, int y, double scale, double rotate, u8 red, u8 green, u8 blue, u8 alpha)
adds all features of frame rendering.ST_RenderCurrentScreen()
will give you the current screen being rendered to
Splashscreen
- You can use the function
ST_Splashscreen(u64 time)
to display a "Made with SpriteTools" splashscreen afterST_Init()
. It's not a requirement, but we appreciate it when people give credit this way.
Animation Frames
st_frame
is a datatype that stores a frame of animation or sprite from a spritehseet.- You can use
ST_AnimationCreateFrame(st_spritesheet *spritesheet, unsigned int xleft, unsigned int ytop, unsigned int width, unsigned int height)
to get a pointer to anst_frame
. - You can use
ST_AnimationFreeFrame(st_frame *frame)
to free an st_frame.
The following functions render frames:
Function | Description |
---|---|
ST_RenderFramePosition(st_frame *frame, int x, int y) |
Draws a frame at a given position |
ST_RenderFrameScale(st_frame *frame, int x, int y, double scale) |
Draws scaled frame at given position |
ST_RenderFrameRotate(st_frame *frame, int x, int y, double rotate) |
Draws rotated frame at given position |
ST_RenderFramePositionAdvanced(st_frame *frame, int x, int y, double scale, double rotate, u8 red, u8 green, u8 blue, u8 alpha) |
Draws scaled, rotated, and blended frame at given position |
Animations
-
st_animation
is a datatype that stores a list of frames as well as information about how they should be played. -
You can use
ST_AnimationCreateAnimation(u16 fpf, u16 loopFrame, u16 length, ...)
to make a pointer to anst_animation
. Make sure you free your animation and its frames withST_AnimationFreeAnimation(st_animation *animation)
ie:st_animation *link_o_walk_down = ST_AnimationCreateAnimation(3, 0, 10, ST_AnimationCreateFrame(link_overworld_s, 30, 2, 18, 24), ST_AnimationCreateFrame(link_overworld_s, 30, 2, 18, 24), ST_AnimationCreateFrame(link_overworld_s, 56, 1, 18, 25), ST_AnimationCreateFrame(link_overworld_s, 82, 0, 18, 26), ST_AnimationCreateFrame(link_overworld_s, 108, 0, 18, 26), ST_AnimationCreateFrame(link_overworld_s, 134, 1, 18, 25), ST_AnimationCreateFrame(link_overworld_s, 160, 2, 18, 24), ST_AnimationCreateFrame(link_overworld_s, 186, 1, 18, 25), ST_AnimationCreateFrame(link_overworld_s, 212, 0, 18, 26), ST_AnimationCreateFrame(link_overworld_s, 238, 0, 18, 26), ST_AnimationCreateFrame(link_overworld_s, 264, 1, 18, 25)); /* -- CODE -- */ ST_AnimationFreeAnimation(link_o_walk_down);
Rendering Animations
You can modify how animations play with the following functions:
Function | Description |
---|---|
ST_AnimationSetFrame(st_animation *animation, u16 frame) |
Sets the current frame of an animation |
ST_AnimationNextFrame(st_animation *animation) |
Adds 1 to the current frame of an animation. Wraps to 0 if needed |
ST_AnimationPreviousFrame(st_animation *animation) |
Subtracts 1 from the current frame of an animation. Wraps to last frame if needed |
ST_AnimationSetSpeed(st_animation *animation, s16 speed) |
Sets the playback speed of an animation |
You can use the following functions to display animations:
Function | Description |
---|---|
ST_RenderAnimationCurrent(st_animation *animation, int x, int y) |
Draws the current frame of an animation at the given position |
ST_RenderAnimationNext(st_animation *animation, int x, int y) |
Draws the next frame of an animation at the given position |
ST_RenderAnimationPrevious(st_animation *animation, int x, int y) |
Draws the previous frame of an animation at the given position |
ST_RenderAnimationPlay(st_animation *animation, int x, int y) |
Plays an animation at the given position. This also accounts for the animation's speed. |