View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide

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.

actorBox.jpg
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.
pictOfActorSubclassForSpider.jpg

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

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