带处理的连续图像 [英] Sequential images with processing
问题描述
我正在尝试按顺序制作我的图像,但每次我这样做都会给我这个错误:" NullPointerException" on images(image [imageIndex],
0,0);并且图像位于数据文件夹中....请帮助我
Hi , i am trying to make my images mive sequentially but everytime i do that it gives me this error :"NullPointerException" on images(image[imageIndex], 0, 0); and the images are located in the datafolder .... Please help me
int maxImages = 10; //图像总数
int imageIndex = 0; //要显示的初始图像是第一个...
//声明一组图像。
PImage [] images = new PImage [ maxImages];
无效设置(){
尺寸(1024,768);
//将图像加载到阵列中
//不要忘记将JPG文件放在数据文件夹中!
for(int i = 0; i< images.length; i ++){
&NBSP; images [i] = loadImage(" book" + i +" .jpg");
&NBSP; // images [i] = loadImage(" 1319735616_misery03" + i +" .jpg");
}¥b $ b frameRate(5);
}
void draw(){
背景(0);
image(images [imageIndex],0,0);
//每个周期增加一个图像索引
//使用模数" %"一旦到达阵列结束时返回0
imageIndex =(imageIndex + 1)%images.length;
}
int maxImages = 10; // Total # of images
int imageIndex = 0; // Initial image to be displayed is the first
// Declaring an array of images.
PImage[] images = new PImage[maxImages];
void setup() {
size(1024,768);
// Loading the images into the array
// Don't forget to put the JPG files in the data folder!
for (int i = 0; i < images.length; i ++ ) {
images[i] = loadImage( "book" + i + ".jpg" );
//images[i] = loadImage( "1319735616_misery03" + i + ".jpg" );
}
frameRate(5);
}
void draw() {
background(0);
image(images[imageIndex],0,0);
// increment image index by one each cycle
// use modulo " % "to return to 0 once the end of the array is reached
imageIndex = (imageIndex + 1) % images.length;
}
推荐答案
你可以检查imageindex中的值或变量imageindex本身是否在draw()方法中正确定义了吗?
Can you check if the value in imageindex OR the variable imageindex itself is defined correctly in the draw() method?
这篇关于带处理的连续图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!