Chapter 8. Animation

 

As we’ve explained in previous chapters, Android devices can do many things. But when learning to program, one of the first things young people usually want to do is create a game, and this often involves animation. Have you ever used or made a flip book—you know, the ones with a stick person walking along the bottom of the page or slam-dunking a basketball? When you see something moving smoothly across a screen, whether it’s a cartoon or a game, what you’re really seeing is a sequence of quickly changing pictures, like in a flip book. Imagine animating a walking zombie. Its position needs to change, which can be achieved by adjusting the zombie’s speed, the direction it’s heading in, and how often it moves (heading and interval properties) in the App Inventor Designer or by letting the user interact with the zombie by clicking buttons, dragging the sprite, tipping the phone, and so on. But if you don’t change the position of the zombie’s legs, it appears to be frozen or floating. To do this in App Inventor, you use a clock timer and lists of images that change each time the zombie moves, giving the appearance of walking rather than floating.

In chapter 3, we briefly explained the coordinate system; in chapter 4, you had a go at designing apps with user interaction; and in chapter 6, you saw the clock in action. In this chapter, we’ll show you how to create short animations and exciting games using these things and more.

Animation type 1: moving sprites using properties

Ballybally app

Animation type 2: Creating movement with a clock timer and user interaction

Cheeky Hamster app

Animation type 3: creating movement using lists and a clock timer

Creepy Spider app

What did you learn?

Test your knowledge