We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › How create a Pimage list
Page Index Toggle Pages: 1
How create a Pimage list? (Read 590 times)
How create a Pimage list?
Jul 13th, 2007, 7:45pm
 
hi community...!
I try to build a class where is a PImage var that contains the pointer of Image.. but return this error:
Code:

java.lang.NullPointerException

at Temporary_9605_3973.draw(Temporary_9605_3973.java:17)

at processing.core.PApplet.handleDisplay(PApplet.java:1355)

at processing.core.PGraphics.requestDisplay(PGraphics.java:564)

at processing.core.PApplet.run(PApplet.java:1450)

at java.lang.Thread.run(Thread.java:613)

java.lang.NullPointerException

at Temporary_9605_3973.draw(Temporary_9605_3973.java:17)

at processing.core.PApplet.handleDisplay(PApplet.java:1355)

at processing.core.PGraphics.requestDisplay(PGraphics.java:564)

at processing.core.PApplet.run(PApplet.java:1450)

at java.lang.Thread.run(Thread.java:613)


Where is the problem?

this is the script:
Code:

listImg[] lista;
int xy = 0;
void setup()
{
size(800,600, P3D);

for(int x=0;x<5;x++)
{
lista = new listImg[x];
}
}

void draw(){
background(0);

for(int i=0;i<5;i++){
lista[i].draw();
xy +=10;
}
}

class listImg{

private PImage img;
listImg(int alfa){
img = loadImage(alfa+".jpg");
println("LOAD : "+alfa+".jpg");
}

void draw(){
xy += 10;
image(this.img,xy,xy);
}
}
Re: How create a Pimage list?
Reply #1 - Jul 13th, 2007, 8:05pm
 
You've got your syntax wrong. I think what you want is:

Code:
 listImg[] lista;
int xy = 0;
void setup()
{
size(800,600, P3D);
lista = new listImage[5]; //lista is an array of 5 PImages.
for(int x=0;x<5;x++)
{
lista[x] = new listImg(x);
}
}

void draw(){
background(0);

for(int i=0;i<5;i++){
lista[i].draw();
xy +=10;
}
}

class listImg{

private PImage img;
listImg(int alfa){
img = loadImage(alfa+".jpg");
println("LOAD : "+alfa+".jpg");
}

void draw(){
xy += 10;
image(this.img,xy,xy);
}
}
Re: How create a Pimage list?
Reply #2 - Jul 13th, 2007, 8:35pm
 
:S Ops....

thanks
Page Index Toggle Pages: 1