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

2018/3/8

Getting error message cannot find symbol - methodCanSee

IlikeThePrequels IlikeThePrequels

2018/3/8

#
Here is my code import greenfoot.*; /** * Write a description of class Ladybug1 here. * * @author (your name) * @version (a version number or a date) */ public class Bug extends Actor { private int beehivesEaten; /** * Act - do whatever the Ladybug1 wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public Bug() { beehivesEaten = 0; } public void act() { followBeehive(); lookForBeehive(); } public void followBeehive() { turnTowards(150,500); Actor beehive = (Actor) getOneIntersectingObject(Beehive.class); move(3); if(beehive !=null) { getWorld().removeObject(beehive); } } public void attackBeehive() { if(!getObjectsInRange(500, Beehive.class).isEmpty()) { Actor beehive=(Actor) getObjectsInRange(200, Beehive.class).get(0); if(beehive !=null) { followBeehive(); } } } private void lookForBeehive() { if ( canSee(Beehive.class) ) { Greenfoot.playSound("wah.mp3"); eat(Beehive.class); beehivesEaten = beehivesEaten + 1; } } } // References
Super_Hippo Super_Hippo

2018/3/8

#
canSee and eat are methods from the Animal class. You can replace canSee with isTouching and eat with removeTouching.
IlikeThePrequels IlikeThePrequels

2018/3/8

#
Thanks man
You need to login to post a reply.