SPANIM. It's not a command the jedi would tell you. It's a sith legend. that many people know how to use. It's useful for making smooth sprite movements, making animations that can play while other functions run, and even making cutscenes. This guide assumes you know the basics of SmileBASIC, sprites, and variable types.
SPANIM is a command that lets you animate sprites. These animations only need to be run once for them to start. At any time during an animation, you can use the SPSTOP command to pause the animation and SPSTART to resume it. Let's break down the average SPANIM command:
SPANIM [sprite ID],[animation type],[animation data],[loop]The sprite ID is the ID of the sprite you want to animate.
The animation type is what part of the sprite you want to animate. There are 8 animation types:
0 or "XY": SPOFS coordinates (needs two values)
1 or "Z": Depth of sprite
2 or "UV": Where on the sprite sheet the sprite's graphics are from (needs two values)
3 or "I": SPDEF definition number
4 or "R": SPROT angle (in degrees)
5 or "S": SPSCALE width and height (2.0 = 2x the size)
6 or "C": SPCOLOR / sprite color
7 or "V": SPVAR variable 7
You can use either the number or the string as the animation type.
The loop parameter is how many times you want the animation to play. If you put 0, the animation will loop forever.
SPANIM ... [time],[data],[time],[data], ...Animation data consists of two parts, repeated until the end of the animation.
The first is a time value. It dictates how long to wait before moving on to the next keyframe. If there's a positive time value, it sets the data value to the animation's data value and waits for the time value. If there's a negative time value, the transition to the next data value is smoothed over the amount of time you selected.
The next is a data value. (Depending on the animation type, there can be two data values per keyframe)
Oh, sorry for not explaining that. Each part of the animation is called a keyframe. Keyframes are points where the data value needs to change.
You can also use DATA labels or one-dimensional arrays to store animation data. If you use DATA labels, be sure to make the first DATA the number of keyframes there are in the animation.
By adding 8 to the animation type, (or adding a + onto the end, if you're using strings) you can make relative animations. Relative animations add to the initial value instead of just resetting it.
0 time values
For some reason, you cannot use a time of 0 to set the initial value of the animation. That means you can't use this:
SPANIM 0,"XY",0,5,5,-15,100,50,1Instead, do this:
SPOFS 0,5,5:SPANIM 0,"XY",-15,100,50,1(or the equivalent of that, like SPCHR if you're using I)
Positive time values
Unlike negative time values, positive time values animate as soon as they are reached, not when the end of the delay is reached.
Smooth animation of SPCHRs
Despite it having pretty much no use, you can smoothly animate SPCHRs. It just flips through all the sprites between the current sprite and the final sprite.
Relative animation is only relative to the original value, so if you did this:SPANIM 0,"XY+",-30,16,0,-30,-16,0it won't go back to the starting point at the end, but go 16 pixels to the left of it.
If you run a SPANIM command twice or use the animation type's equivalent command, the first SPANIM will be overriden by the second command.SPANIM 0,"XY",-60,5,5:SPOFS 0,30,5SPSTART will not resume the first animation.
What about BGANIM?
It's pretty much the same as SPANIM but with BG layers and a few less animation types. Also, colors can't have an alpha channel.
Thank you for checking out my guide on SPANIM! If you have any questions about SPANIM or if you find a problem with this guide, please feel free to comment! Sorry if this was unclear. Half of it was written on a smartphone. I may make a tool to make SPANIMs easily in the future.
Now time for some advertisements for my programs and games. Check out V360 Grab Bag and REALLY GREAT RPG if you like complete wastes of time and storage space.