How to do the Counter
Diapositivas del conjunto (10)
-
- World
- Actor
- We are going to use the example of the a ship and Iceberg in the Ocean world.
-
Code for the World (At the top)

- Pie de imagen: This blue box is adding the counter to the world. Therefore with this reference, the world can link with the actor and the counter. BEWARE NO BRACKETS
-
Code for the World (Near bottom)

- Pie de imagen: This part is especially important. If this is forgotten, the counter WILL NOT WORK.
-

- Pie de imagen: Pay attention to the pink boxes. These links to the world are important as without them, the actor will not be able to work with the counter
-
Version 2 - Different GREENFOOT
- This Greenfoot is for the Newer version.
-

- Pie de imagen: This is a key concept when programming Greenfoot. This is that the various Actors and the World - using references - can communicate or talk to each other. They cannot communicate without references.
-

- Pie de imagen: This is to go in the prepare section in the World. This is adding the Counter object - manually - into the world. This can be done automatically by dragging the counter where you want it and pressing "Save the World".
-

- Pie de imagen: If you could please pay attention to the purple box. The reason the word "counter" is placed in the brackets for when the Turtle is being created is that when that is done, a reference for the counter to the turtle is being created. Now the turtle will know and recognize the counter, therefore it can tell the counter to update a score if needed, when the parameter is updated on to its own class area for coding and programming.
-

- Pie de imagen: This makes the final reference to the Counter. The blue box is focusing on the code while the pink box is focusing on the position of the code. It is before the "act" function.
-

- Pie de imagen: Please focus on the purple box. This is telling the counter to add 5 when the Actor - the turtle in this case - eats another Actor - the Lettuce.
Información
- Descripción
- El usuario ha eliminado su información de asignaturas Diapositivas sobre How to do the Counter, creado por Usuario eliminado el 15/09/2016.
- Creado por
- Usuario eliminado · sep 2016
- Actualizado
- 16 sep 2016
- Visitas
- 14
- Historial
-
- Creado por Leann McLeod · 3 may 2016
- Copiado por Leann McLeod · 15 sep 2016
- Valoración