Multi-sprite animations

Programming with Scratch Jr - Lesson 2

Objectives

  • To program sprites to create a short animation 
  • Program a number of sprites to move together 
  • To use logical reasoning to predict the behaviour of simple programs

Lesson Resources

Introduction

Begin by recapping the last lesson, what is an algorithm? How did we create algorithms in our last lesson? What can you remember about ScratchJr? What sort of blocks did we explore?

Give the students a few minutes to experiment with the blocks that they used in the last lesson (blue, purple and orange) to refresh their memory of how they all work.

Towards the end of the last lesson we looked at this block, what did it do?

 

There are different ways to repeat things in ScratchJr, you may have already discussed two of them last week.

 

Repeat a whole algorithm:

 

Repeat part of an algorithm:

But there is also a third option using a block in the red section. The orange repeat block forces you to say how many times you want to repeat it, and it will always, eventually come to an end. The red repeat forever block does just that, it will keep on repeating the algorithm it is attached to until you press the stop button at the top of the screen. You can also only place it at the end of an algorithm.

 

Repeat forever:

 

We’ll need to use this new method in our work today.

 

Main task

Today we are going to be programming an animated scene that contains several sprites. But what is an animation? Have you done any animating before? There are different kinds of animation which the children may have covered if they have completed our unit of work An Introduction to Animation’ but today we are going to create our animation with code.

Animation is all about making still pictures move. We’ve already made Scratch the cat move, so we’ve kind of animated him already, but let’s take it further and create a whole animated scene!

As well as the repeat forever block, there’s another really important new block we need to know about for this, the ‘start on green flag’ block:

 

 

This is a starter block and, as you might be able to tell by its shape, it can only be placed at the start of your code.

So far we’ve been starting our algorithms just by tapping the blocks. That’s okay when you only have one sprite, but it doesn’t work so well when you have more than one, as all the blocks are on different screens and you can’t tap them all at the same time. Using the green flag block lets us start several algorithms all at exactly the same time! All you have to do is tap the other green flag at the top of the screen, and any algorithm that has a green flag block attached to it will run.

Let’s put it into practice, but first we need to set our scene. Tap on the background icon at the top of the screen to show what’s available.

 

 

We’re going to create an ocean animation today, so select the under the sea icon and tap the tick to confirm it.

 

Cats don’t usually fare too well under the sea! So we’ll swap Scratch for another sprite too. Press and hold you finger on Scratch the cat (keep your finger really still while you hold it down) either in the main screen window or the small thumbnail version on the left of the screen and you’ll see a cross appear, tap the cross to delete the sprite.

 

 

Let’s add a new sprite by tapping the + sign on the left of the screen. There is a big collection of sprites to choose from, but scroll down a bit and you’ll see a selection of under-the-sea creatures such as a crab, fish and others.

 

 

We’re going to add the crab to begin with and give it some code to get it moving. This code makes the crab move quickly, move right 6 steps, say ‘I’m a crab!’ and move left 7 steps (side to side as crabs do) and the repeat forever block keeps it all repeating.

 

 

Ask the students to do something similar on their own version. It’s easier to keep it the same for everyone initially, then perhaps give them the chance to choose their own themes later.

Make sure they all remember the green flag block to start things and a repeat forever loop at the end.

Then demonstrate adding a second sprite by going back to the + sign and choosing another under-the-sea character, such as a fish.  You can switch between the sprites by just tapping the one you want to program in the left-hand list.

Remember, you can drag the sprites to any starting position you want, then add some code to your second sprite making sure you start the code with another green flag block and finish with a repeat forever block. Now when you tap the flag at the top of the screen both sprites will start their algorithms and move!

 

 

Ask the students to add a second sprite of their own and make sure both are moving when they tap the green flag. Then can then continue this by adding more sprites (up to about five), however, they must code and test each sprite before they add a new one, we don’t want to end up with a scene full of sprites that don’t do anything!

Eventually, it might look a bit like the animation in this video:

To finish things off, they can even add themselves to the animation if they’d like to!

When you add a new sprite, look for any of the sprites that have a blank face, the diver is perfect for this scene! Select it and then tap the brush icon at the top of the screen to edit the sprite:

Next, tap the camera button and then the empty face area of the diver and you’ll see your live front-facing camera feed appear in that space.

 

Position the camera so your face fills the space and press the camera button at the bottom of the screen to take the photo. Press the tick in the top right to save and use your special unique sprite in your animation... then don’t forget to program it!

 

 

If you have problems with this part and you cannot see the camera button it will be due to privacy settings on the tablet. The first time someone attempts to use the camera with ScratchJr you will be asked to allow or deny permission for the camera to be used with this app (you often see something similar when trying to access your picture library with apps). If you see this message make sure you press ‘OK’ that you want to allow access to the camera. However, you only get prompted to do this the first time and if someone has already pressed ‘no’ accidentally, then you will need to go into the tablet’s settings to fix it.

On iPads:

Go to Settings > Privacy > Camera > and flick the switch to on/green for the app that you want to access the camera.

If you have similar problems getting the microphone to work you can allow that in the same place (Settings > Privacy > Microphone)

On Android tablets:

Go to Settings > click the app you want to allow > click permission > activate camera

 

Saving

Projects save automatically to your home menu, but you can name and save them by tapping the yellow button in the top right of your screen. From here you can add a title to your project.

 

 

You can also share your projects with others by emailing or Airdropping (iPad only) it to them, but remember they will only be able to open it if they have ScratchJr installed.

 

Plenary

You can view your animations full screen by pressing this button at the top of your screen:

 

Give each student a copy of ‘Circle the blocks.’ Pick a student’s animation to show on the screen at the front in full screen modeFocus on one of their sprites. Ask the students to study what this sprite is doing for a few moments, what do you think the algorithm for this sprite looks like? Ask them to circle any that they think have been used in the no.1 section of their sheet. Repeat with a focus on other characters in the animation (or a different animation if you prefer) Compare after each, did you get the right blocks? This should help you gauge their understanding of the programming.

One of our objectives was to make all the sprites move together, is this happening in the animation we’re looking at? Did it happen in your own animation? How did we make that happen? Reinforce that the green flag block gives a start command to all algorithms that it’s linked to.

< Previous Lesson

Next Lesson >