0

I am working on a simple car game on greenfoot and I wanna add an alert sound if my car is getting closer to a truck

This was my trial in the truck class's act method but it keeps on showing an exception:

if(!getObjectsInRange(60, Car1.class).isEmpty()) 
{
   Greenfoot.playSound("alert.wav");
}

please advise. Thank you.

Mind
  • 9
  • 2
  • 1
    Which access gives the exception? Post the exact and complete message, and at best separate the parts into lines to find it better. Like: `List cars = getObjectsInRange(60, Car1.class); boolean noCars = cars.isEmpty(); if (!noCars) // ...` – the busybee Apr 20 '20 at 07:31
  • What kind of exception does it give? – Martin Rohwedder Apr 27 '20 at 09:39

0 Answers0