Animations
The words after with in a show or hide statement are CSS classes, and the engine’s stylesheet includes two animation libraries whose classes you can name there: animate.css 4.1.1 (entrances, exits and attention seekers such as fadeIn, bounceOutLeft or pulse) and CSShake 1.5.0 (shakes). Nothing needs to be installed or loaded.
Play an animation
Add with and the animation’s name at the end of the statement:
'show scene afternoon with fadeIn',
'show character y happy at right with fadeIn',
'show character y worried with shake',
'hide character y with fadeOutRight'These statements take animations: show scene, show background, show character, hide character, show image, hide image, show video, hide video, show canvas, hide canvas and the character layer statements. Each one’s page in Script Actions has the details.
Names are case sensitive: fadeIn plays, fadein does nothing. A name that matches no animation doesn’t stop the game; the element appears without one.
The animation names
These are all the names animate.css brings, grouped as the library groups them. “In” names bring an element on screen, “Out” names take it away, and the attention seekers play in place.
| Group | Names |
|---|---|
| Attention seekers | bounce, flash, pulse, rubberBand, shakeX, shakeY, headShake, swing, tada, wobble, jello, heartBeat |
| Back entrances | backInDown, backInLeft, backInRight, backInUp |
| Back exits | backOutDown, backOutLeft, backOutRight, backOutUp |
| Bouncing entrances | bounceIn, bounceInDown, bounceInLeft, bounceInRight, bounceInUp |
| Bouncing exits | bounceOut, bounceOutDown, bounceOutLeft, bounceOutRight, bounceOutUp |
| Fading entrances | fadeIn, fadeInDown, fadeInDownBig, fadeInLeft, fadeInLeftBig, fadeInRight, fadeInRightBig, fadeInUp, fadeInUpBig, fadeInTopLeft, fadeInTopRight, fadeInBottomLeft, fadeInBottomRight |
| Fading exits | fadeOut, fadeOutDown, fadeOutDownBig, fadeOutLeft, fadeOutLeftBig, fadeOutRight, fadeOutRightBig, fadeOutUp, fadeOutUpBig, fadeOutTopLeft, fadeOutTopRight, fadeOutBottomLeft, fadeOutBottomRight |
| Flippers | flip, flipInX, flipInY, flipOutX, flipOutY |
| Lightspeed | lightSpeedInRight, lightSpeedInLeft, lightSpeedOutRight, lightSpeedOutLeft |
| Rotating entrances | rotateIn, rotateInDownLeft, rotateInDownRight, rotateInUpLeft, rotateInUpRight |
| Rotating exits | rotateOut, rotateOutDownLeft, rotateOutDownRight, rotateOutUpLeft, rotateOutUpRight |
| Specials | hinge, jackInTheBox, rollIn, rollOut |
| Zooming entrances | zoomIn, zoomInDown, zoomInLeft, zoomInRight, zoomInUp |
| Zooming exits | zoomOut, zoomOutDown, zoomOutLeft, zoomOutRight, zoomOutUp |
| Sliding entrances | slideInDown, slideInLeft, slideInRight, slideInUp |
| Sliding exits | slideOutDown, slideOutLeft, slideOutRight, slideOutUp |
The animate.css website shows each one playing.
Shakes
CSShake adds ten shakes. In Monogatari’s copy each one plays once, for its own length:
| Name | Length | Movement |
|---|---|---|
shake |
0.8s | A small shake in every direction, with a little rotation. |
shake-little |
0.8s | A very small shake. |
shake-slow |
5s | A slow, wide shake. |
shake-hard |
0.8s | A strong shake. |
shake-horizontal |
0.8s | Side to side only. |
shake-vertical |
0.8s | Up and down only. |
shake-rotate |
0.8s | Rotation only. |
shake-opacity |
0.5s | A shake that also flickers. |
shake-crazy |
0.1s | A very fast, wide shake that also flickers. |
shake-chunk |
4s | Strong shakes with large turns. |
shake is CSShake’s. animate.css 4 calls its own shakes shakeX and shakeY.
Speed, delay and repetition
Add these words after the animation’s name, in the same statement:
| Word | What it does |
|---|---|
slow, slower |
Plays it 2 or 3 times as long (2s and 3s by default). |
fast, faster |
Plays it in 0.8 or 0.5 of the time (0.8s and 0.5s by default). |
delay-1s, delay-2s, delay-3s, delay-4s, delay-5s |
Waits that long before it starts. |
repeat-1, repeat-2, repeat-3 |
Plays it once, twice or three times. |
infinite |
Plays it over and over, until a later statement changes the element. |
duration <time> |
Sets the length to any CSS time, such as duration 3s or duration 500ms. Works with show character, hide character, show image, hide image, show scene, show background and the character layer statements. |
'show character y happy with fadeIn slow',
'show character m smiling with bounceIn duration 3s',
'show character y angry with shake-little infinite'The engine writes duration on the element itself, so it wins over slow, fast and the rest. The others are animate.css classes: they work on every statement that takes an animation, and they also change the length of a shake (with shake slow takes 2s).
Change the speed of every animation
slow, fast and the delays are multiples of three variables. To make every animation in the game faster, set the base length in style/main.css:
:root {
--animate-duration: 0.5s;
}Every animate.css animation now takes half a second, slow takes one second, and the shakes keep their own lengths.
Exits: hiding with an animation
A hide statement with an animation plays it, then removes the element when it ends:
'hide character y with fadeOut'While the exit plays, the element has data-visibility="invisible" and the game moves on to the next statement. When the words after with start no animation (a misspelled name, or a class of your own with no animation in it), the element is removed at once.
Plan the exit when the character enters
A class that starts with end- names the animation that takes the sprite away later:
'show character y happy at right with fadeIn end-fadeOut',
'y See you tomorrow.',
'hide character y'The plain hide character y plays fadeOut, because the sprite was shown with end-fadeOut. The same happens when the next show character y statement shows another sprite of Yui: the old sprite plays its end- animation while the new one appears in its place. Write the animation’s name right after end-, as in end-fadeOutLeft or end-shake-hard. This works for characters and their layers. An image shown with an end- class plays it when a plain hide image removes it.
Slide a character to a new place
When a character is already on screen, show it again with a new position and with move, and the sprite slides there instead of jumping:
'show character m happy at center',
'm I’ll wait by the lamp.',
'show character m happy at left with move'The slide takes --character-move-speed (0.2s) with the --character-move-easing curve (ease); set those variables to change it for the whole game. For a single statement, add transition and a time:
'show character m happy at left with move transition 2s'Without move, the sprite jumps to its new place. move only slides a character that is already on screen: a sprite shown for the first time appears at its position.
Your own animation
Any class works after with, so an animation of your own is a @keyframes block and a class that names it, in style/main.css:
@keyframes float-in {
from {
opacity: 0;
transform: translateY(3rem);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.float-in {
animation-name: float-in;
}'show character y happy with float-in'Only animation-name is needed: sprites, images and backgrounds always have the animated class, which gives every animation its length (--animate-duration, 1s) and keeps the last frame when it ends. slow, infinite, duration and the rest work with your animation too. An exit animation of your own works with hide and with end-.
Players who ask for less motion
Players can ask their device to reduce motion (in the system’s accessibility settings). animate.css respects that request, and since every component and every sprite has the animated class, so does most of a Monogatari game:
- every animation finishes at once (in a thousandth of a second) and plays once, even with
infinite; - a character with
movejumps to its new place; - an element leaving with an exit animation (any name with
Outin it) is invisible at once; - the text effects of the Type Writer, such as
{wave}, stop moving.
The same happens when a page is printed. Your own animations follow the same rule when they’re on an element with the animated class.
Related pages
- CSS Variables: the animation and movement variables.
- CSS Classes: how
atandwithbecome classes. - Show Character, Hide Character, Show Scene: the statements, with their options.