We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello.
I'm writing a class to display set of strings nearly - some of them shoud be displayed horizontally and some vertical (these functions belong to TextObj class ).
While inside the class constructor everything works properly, print() inside display() function returns a nullPointer exсeption.
What's wrong with my class?
public class TextObjectGroup {
PVector p;
PVector mod = new PVector(0, 0);
TextObj[] texts; //other class
TextObjectGroup(String textArray[], PVector pos, int size) {
TextObj[] texts = new TextObj[textArray.length];
for(int i = 0; i < texts.length; i++) {
p = new PVector(pos.x + mod.x, pos.y + mod.y);
texts[i] = new TextObj(textArray[i], p);
if(texts[i].vert) {
mod.x = mod.x + size;
} else {
mod.y = mod.y + size;
}
}
print(texts[0].text); // works properly
}
void display() {
print(texts[0].text); // exeption
}
}
Answers
https://forum.processing.org/two/discussion/13529/missing-a