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

2014/3/28

I think Greenfoot is a bit buggy in this case...

Facknowhow Facknowhow

2014/3/28

#
I have some fairly simple code that makes Greenfoot crap itself. World Code:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.*;
import javax.swing.*;
import java.awt.*;

public class MainScreen extends World
{
    public MainScreen()
    {    
        super(600, 600, 1);
        GreenfootImage bg1 = new GreenfootImage(getWidth(), getHeight());
        bg1.setColor(new Color(25, 255, 25));
        bg1.fill();
        bg1.setTransparency(75);
        setBackground(bg1);
    }
    public void act()
    {
        
    }
}
Object Code (extends Actor):
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;

public class Wall extends Actor
{
    private GreenfootImage image1 = new GreenfootImage(32, 32);
    protected void addedToWorld(World world)
    {
        image1.setColor(new Color(0, 255, 0));
        image1.fill();
        setImage(image1);
    }
    public void act() 
    {
        
    }
}
I have no idea why this doesn't work. Maybe its my computer, but when I do this, it looks like this when I add wall object: Greenfoot As you can see, the entire world becomes the same color as the Wall object. Also, whatever button my mouse happens to be hovering over is placed into the top left corner of the world for whatever reason.
danpost danpost

2014/3/28

#
Never change the transparency of the background image of a world. It is the 'backdrop' of your scenario and should always stay opaque.
You need to login to post a reply.