O'Reilly logo

Creating Web Animations by Kirupa Chinnathambi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

Figure 14-1. The sequence of images that make up your sprite sheet

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:

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required