Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 110 - 2612 Digimind C5
P. 110

    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.                          when     clicked

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

                      108   Premium Edition-V

| 105 106 107 108 109 110 111 112 113 114 115 |