Good evening guys,
I have a problem with the game im programming for school. At the moment im trying to make it that the cars for my traffic spawn with a distance. Therefore I created a Actor subclass "SpawnChecker" with a transparent pic the size of the cars im spawning and a boolean method.
This method im trying to access in a world class. But because I have 4 lanes on my street there a 4 SpawnCheckers. In the prepare method of my world I declare them with numbers.
Now, I cant figure out how to run this. This is my if condition:
Iam geting the Error: cannot find symbol - variable spawnchecker2. Probably it has to be SpawnChecker.canSpawn() but I dont know how to combine it with the specific part of code.
Thanks you very much.
public boolean canSpawn() {
if (isTouching(traffic.class)) {
return false;
} else {
return true ;
}
} SpawnChecker spawnchecker2 = new SpawnChecker();
addObject(spawnchecker2, 477, 305);if (lane == 2 && spawnchecker2.canSpawn()==true) { "spawn a car" }
