这是我的代码片段:
这是我的代码片段:
Color[] color = new Color[3];
color [0] = Color.red;
color[1] = Color.blue;
color[2] = Color.yellow;
stage.getBatch().setColor(color[rand.nextInt()]);
但是“color[rand.nextInt()]);”被标为红色下划线。我真的不知道为什么。括号中必须有四个数字或者像“Color.BLUE”一样,而我想要随机着色精灵。因此,我创建了一个具有三种颜色的数组。我认为只需给它们数字并使用rand.nextInt就能使其正常工作。错在哪里?
stage.getBatch()
时,返回的是什么类型? - Alberto S.