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

2021/8/9

undeclared variable is.

madalina.tuturman madalina.tuturman

2021/8/9

#
help, it s my first day here and i m already having problems why isn t my Greenfoot.stop() working in this case?
public class Spaceship extends Actor
{
    public void act()
    {
        if(Greenfoot.isKeyDown("w") )
        move(5);
        if(Greenfoot.isKeyDown("s") )
        move(-5);
        if(Greenfoot.isKeyDown("d") )
        turn(5);
        if(Greenfoot.isKeyDown("a") )
        turn(-5);
        if( is.Touching (Asteroid.class) )
        Greenfoot.stop();
    }
}
danpost danpost

2021/8/9

#
The compiler does not know what object "is" refers to. Nor does it know of any "Touching" method (even if "is" referred to an Actor object). But, it does know about an "isTouching" method for an Actor object. Remove the "." from line 13.
You need to login to post a reply.