For now, we know how to add movement, sounds, events, looks to the sprite, or the project.
In this lesson, we will learn about control commands with the help of Raj and Arun.
Raj- Hello Arun. You told me that next time we will learn to control the scripts.
Arun- Yes! With the help of control commands, we will be controlling the scripts.
Let’s start withandblocks. To see their working, go to the starfish sprite and drag out the block and place it over the scripting area. Select the fish from the drop-down list.
Second, go to fish sprite drag out the block, and place it on the scripting area. Also, drag out block from motion menu and place it under theblock.
Raj- Okay done!
Arun – Now go to the starfish script and click on it. What do you observe?
Raj- Clone of fish is created and this gives command to fish sprite to move.
Arun- Correct! These blocks create clone and trigger the script according to the command.
If you want to delete the clone use block and place it under the script of fish sprite.
Raj- On clicking the script of starfish, no clone is created.
Arun- Correct! This is because as soon as the clone creates the block deletes it.
Arun- Move to next block which is block.
Raj- What is does?
Arun- To see the working, drag out block and place in between and block. And click on script of starfish.
Raj- Fish is moving repeatedly for 10 times.
Arun- Yes! If you want to make your sprite to move continuously use block.
Arun- Replace block with block. Click the script of starfish.
Raj- Yes, the clone of fish is moving continuously but it is going out of the stage area. What should I do to make the clone to move in the stage area?
Arun- Try to remember one block, which bounces the sprite when it touches the edge if the stage.
Raj- Oh! We will use block from the motion menu.
Arun- Correct! Place block below the block. Now click on script of starfish.
Raj- Now the clone is moving continuously and bounces back when touching the edges.
Arun- As you can see the clone is moving very fast, to slow it down use block.
Raj- How to use it?
Arun- Just drag out block and place it in between of and blocks.
Now click on script of starfish.
Raj- Now the clone is moving slowly.
Arun- If you want to stop everything use block below block and click the script of starfish.
Raj- The clone is created but deleted at the end of the program.
Arun- Yes you are right.
Raj- These are amazing blocks now we can control sprites using these blocks.
Arun- There are some more blocks which are conditional based such as block, block, block and block.
Raj- How they control the sprites?
Arun- These blocks I will explain when we will learn about sensing or operators commands.
Arun- Because these commands need conditions to perform the functions. If the condition is true then the task will be completed.
Arun- That’s all in this lesson I hope you understand it. Next, we will be discussing on Sensing commands where you will get to know the working of left-over commands here.