Cover Page by David Geary

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

Chapter 6. Sprites

In the last chapter you learned how to implement animations in a canvas. You saw how to use requestAnimationFrame() to implement smooth animations, and you saw how to incorporate clipping and offscreen canvases into your animations. You also learned how to implement time-based motion and how to time animations with stopwatches and animation timers.

Now that you know the fundamentals of implementing Canvas-based animations, it’s a good idea to encapsulate those fundamentals in some JavaScript objects so that you don’t have to start from scratch every time you implement an animation. This chapter explores the implementation of sprites, which are graphical objects that you can incorporate into animations. You’ll see how to move ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required