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

2013/6/3

Help setting font?

FlyGirl95 FlyGirl95

2013/6/3

#
So I have this method in my class GameText. My other class Text adds a new object GameText and then Game Text sets the image. I don't know how to go about getting the text to be bold. Any help?
public GameText(String text, int val)

   {
        //Set images for the prompt and related responses: want the prompt to look different.
        value = val;
        if (value == 0)
        {
            setImage(new GreenfootImage(" " + text + " ", 17, new Color(92, 7, 1), new Color(255, 255, 255, 50)));
        } else {
            setImage(new GreenfootImage(" " + text + " ", 16, Color.white, Color.black));   
        }
    }
I know there is a specific Font class in Java that can help determine fonts, but I don't know how to use that with Strings or with GreenfootImage. There's also a TextLabel scenario that uses different fonts to create a "Label" GreenfootImage to be set on the screen. However, the code is kinda hard to read and I personally haven't looked at it much. But if you want to, here's the link: http://www.greenfoot.org/scenarios/193 It's also made with an older version of greenfoot, so method names have to be rewritten for it to work properly.
You need to login to post a reply.