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

2018/6/14

How to change color and font of text

jaytan jaytan

2018/6/14

#
showText("Seagull Hunt", 500, 100);
How do I make this a bigger/different font and make it green? Thank you
danpost danpost

2018/6/14

#
jaytan wrote...
<< Code Omitted >> How do I make this a bigger/different font and make it green? Thank you
You can, instead of using showText, add an actor with the desired GreenfootImage text image. Please refer to my Value Display Tutorial scenario.
jaytan jaytan

2018/6/15

#
    public void updateImage(String text)
    {
        GreenfootImage image = new GreenfootImage("SEAGULL HUNT", 24, Color.BLACK, new Color(500,100,0,0));
        setImage(image);
    }
So this is what I have so far, and it says I have no errors but it won't show up on scree (sorry if this is obvious, I'm new to Greenfoot!)
danpost danpost

2018/6/15

#
jaytan wrote...
<< Code Omitted >> So this is what I have so far, and it says I have no errors but it won't show up on scree (sorry if this is obvious, I'm new to Greenfoot!)
Two things: (1) you have text being brought into the method, yet, you use literal text for the image; and (2) if you want the background color to show, it cannot have a zero alpha (transparency) value. Try this for line 3:
GreenfootImage image = new GreenfootImage(text, 24, Color.BLACK, new Color(500,100,0));
If you still do not see it, make sure you are calling the method and the actor is in the world.
You need to login to post a reply.