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

2018/12/6

I'm trying to get the game to stop when actor "car" hits actor "wall1". This is my code but it seems to not work. Could someone please help me, I'm completely new to this.

lorcis__ lorcis__

2018/12/6

#
public void hitwall1()
    {
                
       if (isTouching(wall1.class))
        {
            Greenfoot.stop();
             //stop the game if the car hits the wall
        }           
                  
        }
nolttr21 nolttr21

2018/12/6

#
Make sure your hitwall1 method is called in your act method. It should look something like this
public void act()
{
    hitwall1();
    //other code here
}
lorcis__ lorcis__

2018/12/7

#
Thank you for your help! It works finally :)
You need to login to post a reply.