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

2018/4/9

Creating my own greenfoot image

Morzan189 Morzan189

2018/4/9

#
Hello there! I would like to create an image for an actor used to display a score. Here is the code :
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

public class Stats extends Actor
{
    public void Stats()
    {
        GreenfootImage im1 = new GreenfootImage(100,100);
        im1.drawString("Tirs : 0",0,3);
        im1.drawString(": 0",30,33);
        im1.drawString(": 0",30,36);
        im1.drawString(": 0",30,39);
        setImage(im1);
    }
}
I did add the object in my world, but here is the picture I get : What am I doing wrong? Thanks for your help!
danpost danpost

2018/4/9

#
Morzan189 wrote...
I would like to create an image for an actor used to display a score. Here is the code : << Code Omitted >> I did add the object in my world, but here is the picture I get : << Image Omitted >> What am I doing wrong?!
The compiler does not recognize the code block as a constructor as constructors do not have an explicit return type (they always return the object constructed). Remove void from line 5.
You need to login to post a reply.