Chapter 14. Sprite Sheet Animations Using Only CSS
Sprite sheets can be used for more than just optimizing how you display static images. Hearkening back to the very first arcade games, your sprite sheets can also be used to contain a sequence of images that make up the individual frames of an animation. When these frames are played back rapidly, what you see is a moving picture.
To see this for yourself, visit http://bit.ly/sprite_animation or check out the following video:
This animation relies on a single sprite sheet that contains the individual frames (aka a sprite) of the circles moving. Just a small portion of this sprite sheet looks a bit like Figure 14-1.
While creating all of this seems complicated, it really isn’t. By the time you reach the end of this chapter, you will have learned how to combine a sprite sheet, a CSS animation, and the steps
easing function to create the example just shown.
Creating the Sprite Sheet
This one should be kinda obvious. Before you can animate sprites from a sprite sheet, you first need a sprite sheet. There are a variety of tools out there that help you with this, and my favorite is Flash Professional/Adobe Animate’s Generate Sprite Sheet functionality:
Get Creating Web Animations now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.