I\'m working on a small arcade video game, and I am looking to double buffer to improve animation. I have one class that\'s supposed to draw the blank image, and another class t
You're calling dbg
on the this
instance, not the instance of render
.
You need to change it to
render.dbg.drawLine(....)
Alternatively, if you wanted to leave the dbg
call the same, you could call
this.gameRender();
first and then call
dbg.drawLine(...);
You setup dbg
by invoking gameRender
on render
, but not this
.
Since MC extends render, the dbg
you are referring to belongs to the MC instance that called draw. You can fix it by calling
render.dbg.drawLine( 100, 100, 200, 200 );
or take advantage of the inheritance you implemented
class MC extends Render {
//MC is a render, so you don't need to create another one
public void draw() {
gameRender(); //Call the MC's own gameRender
dbg.drawLine( 100, 100, 200, 200 ); //Calling gameRender initialized dbg so you won't get a NullPointerException
}
}