This site requires JavaScript, please enable it in your browser!
Greenfoot back
sllewis
sllewis wrote ...

2015/6/25

canSee (Worm.class) ) Error. Please Help!

sllewis sllewis

2015/6/25

#
Here is what I have and it is giving me an error code saying: cannot find symbol method cansee. Can anyone help me and tell me why I am getting an error message only on the if ( canSee(Worm.class) ) code? if ( canSee(Worm.class)) { eat(Worm.class); Greenfoot.playSound("slurp.wav"); wormsEaten = wormsEaten + 1; if (wormsEaten == 8) { Greenfoot.playSound("fanfare.wav"); Greenfoot.stop(); } } } }
azazeel azazeel

2015/6/25

#
you should use animal class as superclass
sllewis sllewis

2015/6/25

#
If you dont mind, can you explain what you mean by that?
danpost danpost

2015/6/26

#
The 'canSee' and 'eat' methods are not found in the 'Actor' class. However, they are included in the 'Animal' class which can be imported via the menubar using 'Edit>Import class...' and selecting it to 'Import'. Once it is included in your project, you can have any Actor subclass extend the Animal class to make those methods available.
You need to login to post a reply.