Problems with textWidth
in
Programming Questions
•
2 months ago
Hi there,
I'm new to processing and have been playing with it for a few days. I'm trying to prepare some code so individual letter in a frase disperse and return on pressing a button (everything is already working). But I'm having problems with textWith() giving me an NullPointerException, for no apparent reason. I've searched around but it seems that my problem is different. Nay ideas? here's part of the code (as you can see I'm creating a string as a list of characters using references):
- class PFrase {
- PFrase next;
- PVector location;
- PVector origin;
- PVector velocity;
- PFont font;
- char letter;
- int size =100;
- boolean mode = true;
- PFrase(String str, float x, float y, PFont f) {
- letter = str.charAt(0);
- font = f;
- location = new PVector(x, y);
- origin = new PVector(x, y);
- velocity = new PVector(random(-5, 5), random(-5, 5));
- if (str.length()>1) {
- next = new PFrase(str.substring(1), x+textWidth(letter), y,f); //the problem here
- }
- }
- }
1