public void render() {
if (TimeUtils.nanoTime() - lastSpawn > 2100000000)
chooseLane();
}
private void spawnCar() {
Rectangle car2 = new Rectangle();
float Pos123 = MathUtils.random(0, 2);
if (Pos123 == 0) {
car2.x = 60;
}
if (Pos123 == 1) {
car2.x = 180;
}
if (Pos123 == 2) {
car2.x = 300;
}
car = new Rectangle();
car.width = 100;
car.height = 172;
car2.y = 1000;
car2.setWidth(100);
car2.setHeight(172);
carb.add(car2);
lastSpawn = TimeUtils.nanoTime();
}
精灵每次都在这三个位置中的一个位置进行绘制但是当我执行System.out.println(Pos123)
时,精灵与它产生的实际车道没有关联。这也是将碰撞探测器扔出去的打它,因为它在错误的车道中触发