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

2021/6/19

Why won't "or" not work

Gabe1098 Gabe1098

2021/6/19

#
Hi I just wanted to know why this won't work
public void act() 
    {
        // Add your action code here.
      if (isTouching(Player.class||Spider.class)) {
           setLocation(Greenfoot.getRandomNumber(600),Greenfoot.getRandomNumber(400));
      }
      else {
        GreenfootImage image = getImage();  
        image.scale(80, 30);
        setImage(image);
      }
Gabe1098 Gabe1098

2021/6/19

#
oops I meant in the title "Why won't "or" work
Roshan123 Roshan123

2021/6/19

#
In line 4
if (isTouching(Player.class) || isTouching(Spider.class))
Gabe1098 Gabe1098

2021/6/19

#
Roshan123 wrote...
In line 4
if (isTouching(Player.class) || isTouching(Spider.class))
Thank you so much!!!
You need to login to post a reply.