你能为 Math.random 设置参数吗?
for (Node car : cars)
car.setTranslateX(car.getTranslateX() - 11);
if (Math.random() <= 0.06 ) {
cars.add(spawnCar());
cars.add(SpawnzCar());}
checkState();
}
我希望 Math.random 返回一个介于 0.02 和 0.06 之间的数字
最佳答案
I would like Math.random to return a number between 0.02 and 0.06
为什么不做
0.02 + 0.04 * Math.random();
关于java - 为 Math.random 设置参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41945648/