Animation Basics - RhythmLunatic/stepmania GitHub Wiki

(Insert video here)

This tutorial covers the basics of animating Actors in StepMania, using that (somewhat unimpressive) transition as an example.

There's two important commands you should get to know, and two less important but still useful ones ("n" here means a possible value in the command):

linear() - Takes n seconds to go from the current state to the next. You can chain multiple commands together between linear()s and they'll run concurrently.

sleep() - Waits n seconds before continuing.

decelerate() - Like linear, but starts fast and slows down.

accelerate() - Like linear, but starts slow and speeds up.

If you look at the first few frames of the animation you'll see that there's a flash of white that fades out. That's done like this:

--White, fade out
Def.Quad{
    InitCommand=cmd(setsize,SCREEN_WIDTH,SCREEN_HEIGHT;Center); --Set the quad to the screen's height and width, then center it.
    OnCommand=cmd(linear,0.40;diffusealpha,0); --transition from opaque to transparent, taking .40 seconds.
};```

First the quad is generated and set to the screen's width and height before the screen is shown to the player in the InitCommand. The OnCommand is run when the screen is shown to the player.

Next are the orange lines:
```lua
Def.Quad{
    InitCommand=cmd(setsize,3,SCREEN_HEIGHT;diffuse,Color("HoloOrange");horizalign,right;vertalign,bottom;xy,189,SCREEN_TOP);
    OnCommand=cmd(sleep,.6;decelerate,.7;y,SCREEN_BOTTOM);
};```

```lua
Def.Quad{
    InitCommand=cmd(setsize,3,SCREEN_HEIGHT;diffuse,Color("HoloOrange");horizalign,left;vertalign,top;xy,SCREEN_RIGHT-191,SCREEN_BOTTOM);
    OnCommand=cmd(sleep,.6;decelerate,.7;y,SCREEN_TOP);
};```

As you might have guessed, the sleep command tells it to wait .6 seconds after going onscreen before executing. And although it looks like the bars are getting bigger, they're actually just moving into view from offscreen... (But you can use `croptop()` or `cropbottom()` if you want instead.)

The rest of the objects in the transition aren't particularly important to learn about and are all done using a combination of sleep(), decelerate(), linear(), and/or diffusealpha() commands.

One final thing to note is that setsize() cannot be used with linear, so you should use zoom commands instead.

### The OffCommand
It's like the OnCommand, except it gets executed when a screen is exiting (Usually after you press enter on something).

Here's a trick: Want your screen to wait a few seconds before jumping to the next one (so your sounds don't get cut off)? put a sleep command at the end of an OffCommand and StepMania will wait until it finishes.

Example, because I love examples:
`LoadActor(THEME:GetPathS("ScreenTitleJoin", "GameStart"))..{OffCommand=cmd(play;sleep,5);};`