Scratch Prácticas - Coding in the Elementary Grades
https://sites.google.com/a/tdsb.on.ca/coding-in-the-elementary-grades/tips-tricks/buttons
Buttons & Key Pressed
A Simple Button
| Any sprite can behave like a button. Simply use the event block, "when this sprite is clicked".
When the sprite is clicked it switches the backdrop scene. It is also important to reset to the initial backdrop when the project is started again (when green flag is clicked)
|
Advanced Buttons
| You can use buttons with broadcast commands to signal other sprites for some action.
These blocks of code are for an arrow button. It does different things based on the current backdrop (name) that is loaded. | These blocks of code show and hide the arrow based on the scene it is in, signaled by the broadcast. |
|
On Key Pressed
| You can use keyboard keys as events that can signal code to run.
These blocks respond when any of the directional buttons are pressed on the keyboard. When a directional button is pressed, it points the sprite in the corresponding direction and moves the sprite 10 steps forward.
|
Learning Task 1
| For this task, you will switch the backdrop when a button is pressed. - Open the Scratch Project:
https://scratch.mit.edu/projects/103521636/ - Click on "Remix".
- Edit the button sprite so that it reads "start".
- Code the (start) button to switch to the "soccer" backdrop when it is clicked.
- Code the initial "circles" backdrop to show up when the project is started (when the green flag is clicked).
|
Learning Task 2
Embed gadget
| For this task, you will animate the beetle sprite to move around the screen when the user pressed one of the direction buttons (i.e., up, down, left and right) |
Learning Task 3
| For this task, you will switch (backdrop) scenes based on the current (backdrop) scene and the arrow sprite that is pressed.
Part A - Open the Scratch Project:
https://scratch.mit.edu/projects/103524435/ - Click on "Remix".
- Code the right arrow to load the basketball backdrop when it is clicked
- Code the left arrow to load the playground backdrop when it is clicked
Part B - Code the right arrow and left arrow to change behaviour based on the backdrop it is currently on using a decision statement that checks for the current backdrop name.
- When left arrow clicked and if backdrop name is brick, go to playground backdrop
- When left arrow clicked and if backdrop name is basketball, go to brick backdrop
- When right arrow clicked and if backdrop name is brick, go to basketball backdrop
- When right arrow clicked and if backdrop name is playground, go to brick backdrop
Part C - Code the arrows to hide and show depending on the scene (i.e., brick backdrop show both right and left arrows, basketball backdrop only shows left arrow, and playground backdrop only shows right arrow.)
- Code the sprite character to say different things based on the scene it is in.
|
No hay comentarios:
Publicar un comentario