Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 96 - 2606_PlugGPT_C5_Flipbook
P. 96

    Tick ( ) if you know this.
                           ▶   Variables are a named location where you can store information.

                           ▶   We can create our own variables in Scratch.

                                CONTROLLING THE MOVEMENT OF A SPRITE

                      We can control a sprite by using the sensing block.

                      SENSING BLOCK

                      The Sensing  block  gives  an answer when asked  a question.  Sensing  blocks  are
                      colour-coded with a light-blue shade and are used to detect different sprites and elements
                      of a project including the edge of the stage. They control the movement of the sprite in a

                      better manner. The table given below outlines the code blocks that fit into this category:

                                Blocks                                           Functions

                                                     It checks if its sprite is touching the mouse-pointer, the edge
                                                     or another sprite. If the sprite is touching the  selected object,
                         touching mouse-pointer  ?
                                                     the block returns a true value; if it is not, it returns ‘false’. It is

                                                     used with an if-then block.

                                                     It checks whether its sprite is touching a specified colour. If
                          touching color  ?
                                                     it is, the block returns ‘true’. It is used with an if-then block.

                                                     It makes an input box (with the specified text above it) and
                                                     displays it at the bottom of the screen. The user can then
                        ask  What’s your name?  and wait
                                                     enter  text  into  it  and  submit  it.  The input  is  stored  in  an

                                                     Answer block after that.

                                                     It holds the most recent text entered with the Ask () and Wait
                            answer
                                                     block.

                                                     It checks if the specified key is pressed. If the key is being
                         key  space   pressed?
                                                     pressed, the block returns ‘true’; if it is not, it returns ‘false’.

                      Let us create a program and hear your cat meow.
                      Step  1    Click the Event button to show the Event blocks.

                      Step  2    Drag a When...clicked block to the code area.                             when     clicked

                       94   Premium Edition-V

| 91 92 93 94 95 96 97 98 99 100 101 |