






Instructions for creating a new Actor subclass in Greenfoot
Right click on the Actor box in the UML diagram shown on the right side of the Greenfoot window.

You will see a menu. Select "New subclass". The new class window will appear. Fill in the "New class name" as Spider and pick the spider image in Animals. Then click on the "OK" button.

You will now have a Spider class in the UML diagram.

Double left click on the Spider box to open the Java source code. Add code to allow the Spider to eat an ant if it intersects with it. See the code in Breakout for how we tell if the ball has hit anything to see if the Spider intersects with an ant.
Link to this Page