Quick dumb question
in
Programming Questions
•
2 years ago
Okay I feel a little guilty for asking this question but...
I'm starting a new project with a class called Background, and the method updateBG in the Background class works when it is called from setup() but not draw() (it gives me a null pointer exception).
Here's the full code of my project so far...
- int x;
- Background bg;
- void setup(){
- size(800,400);
- Background bg = new Background(0,40,60);
- updateBG(); //this works
- }
- void draw(){
- print("test");
- bg.updateBG(); //this doesn't
- }
- class Background {
- Background(int r, int g, int b){
- background(r,g,b);
- }
- public void updateBG(){
- background(255);
- }
- }
1