Once the Actor class is added it a World they become 'objects'. An Actor can be any object, Assigned to that actor are methods and there is where the Actor can be set to do various things..
In Greenfoot, a method is the name given to an action that has been programmed into an object. For instance, the object could move forward, turn, make another object disappear, play a sound, etc. Methods happen when a scenario is run.
Every object that is an Actor class has a method called ‘act()’. This is where any actions that the object will do happen, for example move(). This method is created automatically, ready for code to be added to it.
Click on the video tutorial below and this will remind you of how to add Actors in to your World.
(Note: You will not be able to use the same images as the tutorial so just use any images you want)
Now you have Actors in your World, Click on the video tutorial below and this will show you the code to make the Actor move under the cursor keys.
Key Code to Remember
i.e. image will move without the users control
Click on the video tutorial below and this will show you the code to make the Actor move automatically
Key Code to Remember
Note: There are many ways to make an Actor move.
This example shows the Actor moving automatically move(1); and turning using the left and right cursor keys only.
The Actor also turns in the opposite direction turn(180); when it reaches the edge of the world, using isAtEdge()
i.e. image disappears when it touches something else
Click on the video tutorial below and this will show you the code to make an Actor disappear
Key Code to Remember