How do you pick a random costume?


1 2 3 4 5 6 7 8 9 | int costume = Greenfoot.getRandomNumber(the number of costumes you have); if (costume== 1 ) { setCostume(a costume); } if (costume== 2 ) { setCostume(a costume) } |
1 2 3 4 5 6 | String [] costumes = { "image1.png" , "image2.png" , "image3.png" ); ... int index = Greenfoot.getRandomNumber(costumes.length); setImage(costumes[index]); |