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

2014/10/30

Changing font inside of a score counter

RawbyTheSheeth RawbyTheSheeth

2014/10/30

#
I'm making a game that is very retro themed, and I would like to know how to change the font inside of my score counter to be more consistent with the game. I was thinking of the font "fixedsys." Any help would be appreciated. Here's the code for my counter:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
import java.awt.Font;
 
{
    int totalScore = 0;
 
    public void addedToWorld(World world)
    {
        setImage(new GreenfootImage("Score : " + 0, 27, Color.YELLOW, Color.BLACK));
    }
 
    public void bumpCount(int amount)
    {
        totalScore += amount;
        setImage(new GreenfootImage("Score : " + totalScore, 27, Color.YELLOW, Color.BLACK));
    }  
 
    public void addScore()
    {
        totalScore++;
    }
}
danpost danpost

2014/10/30

#
I do not know how easy it would be to change the default font of a new GreenfootImage object (if it is at all possible). However, I have a subclass for the GreenfootImage class that makes text images that use a given font. It is located in my TextImage Support Class scenario.
You need to login to post a reply.