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

2017/10/25

New version

jacquelinereilly jacquelinereilly

2017/10/25

#
I used Greenfoot last year and created a project. It worked just fine, but I got a new computer and had to re -install Greenfoot, and now the project doesn't work. It says if I want it to automatically fix the code, or I can do it manually. I pressed manually, I wasn't sure. But now some of my actors have errors, I guess because of the new version. Any way to fix it or do I have to go through the code again?
danpost danpost

2017/10/25

#
The main things that you would need to do manually are: (1) remove all 'import java.awt.Color;' lines and any 'java.awt.' explicitly coded before the 'Color' class name; (2) change all constant color references to all uppercase (e.g. 'darkGray' to 'DARK_GRAY'); and (3) change all 'null' references used for color to explicit colors when using the 'GreenfootImage(String, int, Color, Color)' constructor (e.g change 'new GreenfootImage("Some text", sizeInt, null, null)' to 'new GreenfootImage("Some text", sizeInt, Color.BLACK, new Color(0, 0, 0, 0))' which used to be the default foreground, black, and background, transparent, colors for a new text image) If you used the 'java.awt.Font' class, there will be more things you will need to change. Just ask if you need to know what to do there.
jacquelinereilly jacquelinereilly

2017/11/1

#
So I should change this?
public MenuGreeting(String txt)
    {
        //Text settings
        GreenfootImage image = new GreenfootImage(600,400);  
        image.setColor(java.awt.Color.red);
        image.setFont(new java.awt.Font("GungsuhChe", java.awt.Font.PLAIN, 29));
        image.drawString(txt, (int)image.getWidth()/2,(int)image.getHeight()/2);
        setImage (image);
    }
danpost danpost

2017/11/1

#
jacquelinereilly wrote...
So I should change this? < Code Omitted >
Yes. Remove 'java.awt.' from in front of 'Font' and replace 'java.awt.Font.PLAIN' with 'false, false' on line 6.
jacquelinereilly jacquelinereilly

2017/11/1

#
Fixed it! Thank you. I actually like the new version better. Thank you
You need to login to post a reply.