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.
Hi. Do sprite sheets used for css animation have to be one wide sprite with the same height? Instead of more of a typical sprite sheet like the ones used in games that’s more rectangular with sprites all over the sheet?
Unfortunately, yes. The reason is that the step function only goes in one direction. Besides one really wide row, you can have one really tall column instead. You just can’t have a grid like you would in other scenarios.
If you are using sprite sheets in JavaScript, then you can more closely mimic what games to pretty easily.
Hi, this is very good, thanks. I have one slight issue and I’m not sure what is the best way to proceed. How do I make the animation responsive? Do i have one sprite per viewport supported (one for mobile, tablet, desktop for example) and then use media queries to adjust the fixed widths / heights? Or is there a better option where I can use just one sprite and adjust its size using relative values? I can’t really think how you could do that without breaking the animation though.
Thanks for your quick reply. I managed to make it responsive with a slightly different approach while using just one sprite image (using vertical sprites) -
HTML
div class=“animation-container hand-alien-container”>
div id=“hand-alien” class=“large-animation”></div
div