Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何从文本中输出的数组中放入随机图像_Java_Arrays_Image - Fatal编程技术网

Java 如何从文本中输出的数组中放入随机图像

Java 如何从文本中输出的数组中放入随机图像,java,arrays,image,Java,Arrays,Image,如何使随机图像从阵列中获取并显示在程序上 这个程序应该在背景上显示这个图片 PImage [] wcArray = new PImage [10]; // This is the array and all of the images that are in the array wcArray [0] = loadImage ("asdfg0.png"); // These are all of the inputed images in each of the arrays wcArray

如何使随机图像从阵列中获取并显示在程序上

这个程序应该在背景上显示这个图片

PImage [] wcArray = new PImage [10]; // This is the array and all of the images that are in the array

wcArray [0] = loadImage ("asdfg0.png"); // These are all of the inputed images in each of the arrays
wcArray [1] = loadImage ("asdfg1.png"); //1
wcArray [2] = loadImage ("asdfg2.png"); //2
wcArray [3] = loadImage ("asdfg3.png"); //3
wcArray [4] = loadImage ("asdfg4.png"); //4
wcArray [5] = loadImage ("asdfg5.png"); //5
wcArray [6] = loadImage ("asdfg6.png"); //6
wcArray [7] = loadImage ("asdfg7.png"); //7
wcArray [8] = loadImage ("asdfg8.png"); //8
wcArray [9] = loadImage ("asdfg9.png"); //9

   pushMatrix(); // This is the actual code that displays the image on the screen from the array
   translate(715,242);
   scale(.56);
   imageMode(CENTER);
   image(wcArray[0], 0, 0); //This displays the actual image from the array on the screen
   imageMode(CORNER);
   popMatrix();

}

您可以使用随机数替换
wcArray[0]
,而不是使用范围内的随机数。看看如何在这里得到一个,似乎奇怪的是
pushMatrix()
出现在
图像之前(wcArray[0],0,0)
您可以使用随机数替换
wcArray[0]
而不是0,您可以使用范围内的随机数。看看如何在这里得到一个,似乎奇怪的是
pushMatrix()
出现在
图像之前(wcArray[0],0,0)