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

3 days ago

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__

3 days ago

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

3 days ago

#
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__

2 days ago

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