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

2013/7/6

I am trying to get player1 to eat the baloons to gain points but it keeps giving me the error cannot find symbo - method canSee(java.lang.Class<Balloon>)

qsapp.3 qsapp.3

2013/7/6

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
 * Main Player
 * Must reach finishline while getting all of the balloons.
 * @author (Quinn Sapp) 
 * @version (28 June 2013)
 */
public class Player1 extends Actor
    {
    public void act(){
        checkKeyPress();
        lookForBalloon();
    }// end act
    public void checkKeyPress(){
        if (Greenfoot.isKeyDown("left")){
            turn(-4);
        }
        if (Greenfoot.isKeyDown("right")){
            turn(4);
        }
        if (Greenfoot.isKeyDown("up")){
            move(4);
        }
        if (Greenfoot.isKeyDown("down")){
            move(4);
        }
        if (Greenfoot.getRandomNumber(100) < 10){
                turn(5);
        }
    }
    public void lookForBalloon(){
        if(canSee(Balloon.class)){
            eat(Baloons.class);
            Greenfoot.playSound("au.wav");
        }
    }
}//end class
danpost danpost

2013/7/6

#
The 'canSee' and the 'eat' methods are not part of the 'greenfoot' package. They are included in the 'Animal' class that you can import using 'Edit'>'Import class...' from the menubar in the Greenfoot application. After importing the class you need to change the class that Player1 extends to the Animal class; then the method calls will work. As an alternative you can copy/paste the needed methods from the Animal class to the Player1 class and then remove the Animal class from your project.
qsapp.3 qsapp.3

2013/7/6

#
THANK YOU SO MUCH!
You need to login to post a reply.