This site requires JavaScript, please enable it in your browser!
Greenfoot back
valdes
valdes wrote ...

2017/7/14

Problem with GreenfootImage constructor

valdes valdes

2017/7/14

#
Why doesn't these lines work:
GreenfootImage text1 = new GreenfootImage(" ", 20, Color.BLACK, null);
GreenfootImage text2 = new GreenfootImage("any text", 20, Color.BLACK, null);
GreenfootImage text3 = new GreenfootImage("any text", 20, null, null);
Anywhere you put them, generates a NullPointerException. Acording to Greenfoot documentation, it should work, creating a text with font size 20, color black and transparent background. I am using version 3.1.0.
Super_Hippo Super_Hippo

2017/7/14

#
It will work in the next version of greeenfoot. Right now it is a known bug. Try to pass a transparent color instead of 'null' in the meantime:
new GreenfootImage("any text", 20, Color.BLACK, new Color(0,0,0,0));
Same thing with the black font color. It doesn't work as a default color when passing null right now.
valdes valdes

2017/7/14

#
Thank you very much!
You need to login to post a reply.