Hello everyone
I have a problem with this piece of code. My animation should change sometimes a text.
I made in my constructor class Rechtecke a reference to world with also a field world.
But I always get a Nullpointer Exception, but I can' t understand it.
Thanks a lot for your help
Mario
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | import greenfoot.*; public class Rechtecke extends Actor { private int r,g,b; private World world; //Reference zu World; public Rechtecke() { GreenfootImage image = new GreenfootImage( 450 , 300 ); image.setColor( new Color( 255 , 0 , 0 , 255 )); image.fillRect( 0 , 0 , 450 , 300 ); this .setImage(image); //causes Nullpointer Exception world = this .getWorld(); world.showText( "Hello World" , 50 , 50 ); } |