SWL+Lesson+5+Work+with+the+Stage

=Scratch Lesson 5: Work with the Stage = media type="file" key="Scratch Lesson5 Get On the Stage med.mp4" width="805" height="465"

In this lesson, I will show you how to make sprites move to certain locations on the Stage. The Scratch Stage uses X-Y Coordinate System that looks as follow:

To demonstrate how to let sprites move by themselves, we will create a basic scene and three sprites with very simple scripts. A scene, like a movie scene, sets the tone of the story and provides a platform for the characters in the story.

First, double click to select Stage. Click “Costumes” tab and there is a default background called “background1”. Click “Edit”. Use Line Tool, Box Tool, and Circle Tool to create outline of two houses and a plate. Then use Fill Tool to fill in colors. When done, hit “OK”. Step 2: Adding Simple Movement Scripts to Sprites If you have not already, create three sprites: Mr. Meow (use the Scratch Cat), Donut Man, and Donut. Now let’s add scripts so that all sprites will show up in the right places when the animation starts (when the Start Flag is clicked).
 * Step 1: Create a Simple Scene**


 * < Move three sprites as shown at the right. Donut Man to the green house, Mr. Meow to the red house, and Donut to the plate. ||< [[image:https://lh4.googleusercontent.com/P7_1uQ2YSerCUinFURq8D6BtwTZSCOv9FmLBYcDE8tbfYGKtfydpGhgs71pN1R6pKxZ1XBvKWmQChB42O_zpizFPq-APhXRP1IH6Oz61DZJU9hTnyeo width="230" height="259"]]* ||


 * < The x-axis and y-axis values are updated accordingly when moved. When a sprite is moved, the Motion blocks (“go to x=? y=?” block and “glide ? secs to x: ? y: ?” block) in the Tool Box are updated as well. ||< [[image:https://lh6.googleusercontent.com/tHh6etHkvRmM5B62L8Sy6bp5DQowHuwWikSf2CzpcTkBLMFyGm8Z77MQHqZdoLoQYl7fom8SDF5UaPQwcgLcNiBWV-1fZG7xYW05Mp52K4d4lBwMkns width="226" height="111"]]* ||< [[image:https://lh6.googleusercontent.com/WBEwznuIlKKPZQ3_8NThwv2vz33mbtuMWnAF7ZsbyTyA7-CCRZ1zRl669Gc-iuc45JDQx50f3u5jrC0ATpF6CRnfQ5KehcqQve02iioU70SlDuSzdtc width="199" height="347"]]* ||


 * < To build Mr. Meow’s scripts, select Mr. Meow from the Sprites Area, then click “Scripts” tab. From the Tool Box, click the “Control” button and drag “when Start Flag clicked” block to drop it in Scripts work area. ||< [[image:https://lh5.googleusercontent.com/C30AQwnRvj-bx1YseO4bSHA8jd2DOy8qaZj5Mlux4fMTg5W0Jlm3vF4xaIM-7PhgR9YhQHX--u_D3ikPqyCRO2uAynE_xGMqF6OLh2qaG68qZKUFko8 width="187" height="263"]]* ||


 * < Then click “Motion” button in Tool Box Selection and drag “glide 1 secs to x:-183 y:-110” to the Stage. Then attach it under the “when Start Flag clicked” block. ||< [[image:https://lh5.googleusercontent.com/VKANOuG9sI2mshOJJiWZkWBwLTzisjAvKv1HzCZwU7cde2aolSBgmve_12gXFDwsNZp1cNZSG3O26BalIMiNgp6-lp1jU5o2IF7B8S9v1ew0WnMYXv0 width="194" height="58"]]* ||


 * < Then click “Looks” button in Tool Box Selection, and drag “switch to costume1” to the Stage. Then attach it under the “glide 1 secs to x:-183 y:-110”. ||< [[image:https://lh6.googleusercontent.com/pTPZ0jvTo7QtJUbd3NPUa3Ym6ytH-MOKGuuFUbSIUJIcTCh4mOq6unUhQwckMfF3JCTsCVxYoJvKBG-5AD_Dw9n3c9yek_3U9NvCrZ5wszo589T_JiY width="194" height="79"]]* ||

Step 3: Do the same for Donuts Man and Donuts In the same way, create similar scripts for the Donut Man and the Donut. Below is what result scripts should look like. Note that your x-axis and y-axis values will very likely be different than mine, and it’s OK.


 * < [[image:https://lh5.googleusercontent.com/dkdg4tbfD9FfXTGf8fBjaFTHyiIVLx8D36AYTYdequJkH0bEpHGBqTHd2I2sw56EsboZrwSbEk9vEf60_Fmuy4Z33CJzJTdWSzw1-kM_w-XujAtYxCA width="204" height="181"]]* ||< [[image:https://lh4.googleusercontent.com/wwli3S1lc_WX7ytZqS7NwG0BY4eje-ZsV5G9RjUG5Q1RRnDb4mWtrjyfyunwyNJ8QPygI24nIY-crsgPiMAsv3ISKXSUxQ8VUVvCvjhRZrhOU-_ATTs width="218" height="181"]]* ||< [[image:https://lh3.googleusercontent.com/PanP87elDx4PruwaQsUZ7vGX18M_k1nVTTOsFOWczNOrz4tkhE2FZItqiWbLDIVBkXZDnLwedIKxM9LP7uRlfF8B5y_Ws5rLvHvAuNOvJzc1jc-BHOw width="199" height="182"]]* ||

* TEST: Move sprites around in the Stage and clicking the Start to see all of the sprites gliding back to their positions.

= Link to Lesson 6 =