Reader small image

You're reading from  Raspberry Pi Projects for Kids (Second Edition)

Product typeBook
Published inApr 2015
Reading LevelBeginner
Publisher
ISBN-139781785281525
Edition1st Edition
Languages
Right arrow
Author (1)
Daniel Leonard Bates
Daniel Leonard Bates
author image
Daniel Leonard Bates

Daniel Bates is a computer science researcher at the University of Cambridge. His day job involves inventing designs for future mobile phone processors and when he gets home, he likes playing games or working on one of his coding projects (or both!). Daniel has been a volunteer for the Raspberry Pi Foundation since 2011 and is enthusiastic about introducing new people to computing. He has previously written Instant Minecraft: Pi Edition Coding How-to and Raspberry Pi Projects for Kids (First Edition), both published by Packt Publishing.
Read more about Daniel Leonard Bates

Right arrow

Interactive animation


We now have two different animated sprites, each doing their own thing. One of the special features of Scratch is that it makes interactive animation simple—we can program a sprite to react to you!

Create a new sprite in the same way as you did before using the Choose new sprite from file button. For this animation, we're going to have a simple conversation with the user, so choose an image of something that can talk. Find a good position and size for the new sprite, then build the following script in its script area:

There are a few new code blocks here. Let's go through them one by one:

  • ask and wait: This gives the sprite a speech bubble, asking a question in a box. This block can be found in the Sensing section. The script will stop until the user has typed an answer into a text box on screen.

  • answer: The answer to the question is stored in this block, and is also in the Sensing section.

  • join: This takes two pieces of text and merges them into a longer sentence.

  • say...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Raspberry Pi Projects for Kids (Second Edition)
Published in: Apr 2015Publisher: ISBN-13: 9781785281525

Author (1)

author image
Daniel Leonard Bates

Daniel Bates is a computer science researcher at the University of Cambridge. His day job involves inventing designs for future mobile phone processors and when he gets home, he likes playing games or working on one of his coding projects (or both!). Daniel has been a volunteer for the Raspberry Pi Foundation since 2011 and is enthusiastic about introducing new people to computing. He has previously written Instant Minecraft: Pi Edition Coding How-to and Raspberry Pi Projects for Kids (First Edition), both published by Packt Publishing.
Read more about Daniel Leonard Bates