Chapter 6 - events

Solo disponible en BuenasTareas
  • Páginas : 5 (1209 palabras )
  • Descarga(s) : 0
  • Publicado : 14 de marzo de 2012
Leer documento completo
Vista previa del texto
What is an event?
• • • An event is an action that takes place while an Alice world is playing. Alice worlds are capable of detecting events and responding to them. Event handlers o A method used to perform the actions that you want to take place in response to an event. o In other words, it is a method executed in response to an event. When the world starts event occurs as soon as you click thePlay button to run a world.



Event
When the world starts

Description
This event occurs immediately when the world is started. It happens only once, each time the world is played. This event occurs as long as the world is running. When the user types a key on the keyboard, this event occurs when the key is released. This event occurs while the user holds down a key. This event occurswhen the user clicks an object in the world with the mouse. When the user clicks an object with the mouse, this event occurs while the user holds down the mouse button. When a condition that you have specified becomes true, this event occurs as long as the condition remains true. This event occurs when a condition that you have specified becomes true. This event occurs when a variable’s valuechanges. This event allows the user to move an object in the world by clicking and dragging it with the mouse. This event allows the user to move an object in the world by typing the arrow keys on the keyboard. This event allows the user to move the camera through the world by clicking and dragging the mouse. This event allows the user to change the camera’s orientation (the direction in which it ispointing) by clicking and dragging the mouse.

While the world is running When a key is typed While a key is pressed When the mouse is clicked on something While the mouse is pressed on something

While something is true

When something becomes true When a variable changes Let the mouse move < objects>

Let the arrow keys move < subject>

Let the mouse move the camera

Let the mouseorient the camera

What is an event? (Continued)
• Handling the event o The process of responding to an event o In order for an Alice world to handle an event a tile called the When the world starts has to appear in the Events Editor Create a new event button o You click it in order to create a new event Specialized Events o Steps to create a specialized event To create one of these special eventsyou first need to select a general event After you have selected a general event right-click it and choose change to in the pop-up menu • This allows you to create a more specialized event

• •

Event
While the world is running While a key is pressed While the mouse is pressed on something

How to Create it
Create the tile for When the world starts event; right-click the tile and selectchange to Create the tile for When the key is typed event; right-click the tile and select change to Create the tile for When the mouse is clicked on something event; right-click the tile and select change to Create the tile for While something is true event; right-click the tile and select change to

When something becomes true

Handling Key Press and Mouse Events
• While a key is pressedevent o This event is triggered when the user types a key on the keyboard and then releases the key. Available keys in the Any Key Placeholder are: o ↑ o ↓ o o  o Spacebar o Enter While the Key is pressed event o This event occurs as long as the user holds down a key. o The new tile has four different placeholder slots: one for the key, and then three others labeled Begin, During, and End. This typeof event is known as the BDE event











While the Key is pressed event (continued) o When you create a BDE event, you specify an action to take place: At the beginning of the event ( the moment that the event occurs) During the event ( the time during which the event is taking place) At the end of the event ( the moment that the event stops occurring) When the mouse is...
tracking img