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

2020/3/22

Walls in a maze

HelpMehCode HelpMehCode

2020/3/22

#
Im having trouble making walls for a maze game. I tried using color but it isn't working. I tried a lot of things seen on this site. It keeps saying that it "can not find variable - BLACK"
public boolean hitWalls()
    {
        if (isTouching(Color(BLACK)))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
danpost danpost

2020/3/22

#
The isTouching method only checks for touching actors of a specified class, which must be a subclass of the Actor class or, for any actor of ANY subclass of Actor, the Actor class itself. Also, "Color(BLACK)" is not a thing; it should be "Color.BLACK". I will presume that your walls are just included in the image that is the background of the world. You can either place transparent actors at all wall location to have something that can be touched or you can check the color at specific coordinates on the world background image.
HelpMehCode HelpMehCode

2020/3/23

#
Thank you so much for the correction for "Color(BLACK)". I fixed that and there is a different error. I am posting a new thread of the updated error code. Again, thank you so much.
You need to login to post a reply.