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

2015/1/15

Greenfoot Scoreboard text issue?

Zwadouggie Zwadouggie

2015/1/15

#
I am wondering if someone is having a similar issue to mine. I have a scoreboard class that increments and updates its own image properly, however, every time the points increment, the image has this ugly white border around it instead of how it normally should look. I am setting font, and I am sure that my updateImage() method has no changes in terms of how the text should look. But it always happens. Does anyone know what to do.
danpost danpost

2015/1/15

#
Please show that code for the class of your scoreboard. Without it, how can one discern what could possibly be going on. Use the 'code link below the reply box to insert code into your posts.
Zwadouggie Zwadouggie

2015/1/15

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.*;
/**
 * Write a description of class Score here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Score extends Actor
{
    GreenfootImage image;
    
    public int score = 0;
    
    public Score ()
    {
        image = new GreenfootImage(150,50);

        image.setFont(new Font("Britannic Bold", Font.PLAIN, 18));

        image.setColor(Color.RED);
        image.drawString("Score: " + score, 5, 45); 
        setImage(image);
    }

    public void changeScore (int newScore)
    {
        score = newScore;
        updateImage();
    }

    public void updateImage ()
    {        
        image.clear();
        image.setColor(Color.RED);
        image.setFont(new Font("Britannic Bold", Font.PLAIN, 18));
        image.drawString("Score: " + score, 5, 45);
    }  

}
This is the Score Class.
danpost danpost

2015/1/15

#
Whatever is going on, it is not caused by anything within this class. This class works fine as is (tested and approved). To see if it is something within the scenario or something that is more systemic, create a new scenario, fill the background of the world with some non-red color, sub-class the Actor class with this Score class and test it. If it works with no problems in the test scenario, you can then by process of elimination determine the cause within the project scenario (comment out blocks of code until the problem goes away -- then start uncommenting bits of it until it returns).
You need to login to post a reply.