我正在嘗試根據隨機整數的值更改我擁有的圖像,但是,eclipse 表示 rand 整數需要一個主體。我已經嘗試過int rand = random.nextInt(4);但這也行不通。任何幫助將不勝感激。public class GrassTile extends Tile { Random random = new Random(); static BufferedImage texture; int rand; rand = random.nextInt(4); if (rand == 0) { texture = Assets.grass0; } else if(rand == 1) { texture = Assets.grass1; } else if(rand == 2) { texture = Assets.grass2; } else if(rand == 3) { texture = Assets.grass3; } public GrassTile(int id) { super(texture, id); }}謝謝,JavaDev
添加回答
舉報
0/150
提交
取消