"> ");
100%
LESSONS & TOPICS

Events and Sprite Communication

Events and Sprite Communication

 

Video – Events and Sprite Communication

 

 

#accordions-597{display: none;}
#accordions-597 {
text-align: left;
}
#accordions-597{
background: url() repeat scroll 0 0;
padding: 0;
}
#accordions-597 .accordions-head{
background:rgba(129,215,66, 1) none repeat scroll 0 0;
margin:1px;
padding:10px;
}
#accordions-597 .accordions-head-title{
color:#ffffff;
font-size:14px;
font-family:;
}
#accordions-597 .accordions-head-title-toogle{
color:#ffffff;
font-size:14px;
}
#accordions-597 .accordions-head:hover .accordions-head-title{
color:#000;
}
#accordions-597 .ui-state-active{
background: #4b8fe3;
}
#accordions-597 .accordion-content{
background:rgba(255,255,255,1) none repeat scroll 0 0;
color:#333333;
font-size:13px;
font-family:;
margin:0;
padding:10px;
}
#accordions-597 .accordion-icons{
color:#565656;
font-size:16px;
}
#accordions-597 .accordions-head:hover .accordion-icons{
color:#999;
}
#accordions-597{}
#accordions-597 .accordions-head{}
#accordions-597 .accordion-content{}

Video Transcript

Hello

When we create electronic games we often want some actions of the heroes to take place in the same time.

Also we want the different sprites we use to communicate with each other.

So games become more interesting.

You will find the answers to the above 2 issues in the upcoming video by Stevie.

Please watch carefully.

 

Hello,

Events are the various events that can be made in the progress of the game we create and cause the execution of specific instructions, therefore also behaviors in the sprites of this game.

An event we have encountered in Scratch several times is the command: “when the green flag is clicked”.

This instruction basically proceeds to execute the instructions that follow when the user clicks on the green flag, i.e. when he causes the specific event.

In addition to the specific events we have just mentioned, very important events we often use are the following

  • When a specific button is pressed
  • When you click on a specific sprite
  • When a specific message is received.

It is important to say that when an event occurs, such as pressing the green flag, more than one piles of code can run.

Watch the scenario we will assign to one of the lions that chases the monkey, in the game we will create in the next lesson.

Notice that there are 2 piles of codes running when the green flag is clicked.

This code runs at the same time.

Very often there is a need for communication between the sprites of our game.

For example, in the game we talked so much about in this lesson, where the monkey chases bananas, let’s assume that as soon as the player has accumulated 10 points, another character must appear, let’s say, Gas, and he will say the phrase “Congratulations you reached 10 points” and then he will disappear.

Let’s see what we want to do in practice and then let’s see how it happened (video follows)

Let’s look at the solution to this problem. We’ll need to use the ‘Broadcast’ command and the ‘When I receive a message’ command.

Soon we can say that once the points reach 10, the banana character (which measures the points) shows the message “10 points”.

Any character can communicate messages.

Messages are streamed to all sprites.

In order for the sprite to hear this message, in our case Gas, it must dispose the event “When I receive the message”.

Let’s now see how we have achieved the appearance of the “Gas” object at the right time.