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

2018/2/27

public void addedToWorld (world name)

emzy112 emzy112

2018/2/27

#
I'm having trouble with my game as every time I type this code in just after the bracket it shows red. can someone help me, please I have tried without the bracket and with a semicolon and nothing is seem to be working
import greenfoot.*; 
import greenfoot.Color;
public class Lazer extends PacMan
{
    public void addedToWorld(WorldSky)
    {
        GreenfootImage image=new GreenfootImage(20,10);
        image.setColor(Color.ORANGE);
        image.drawLine(0,5,image.getWidth()-1,5);
        setImage(image);
    }
}
danpost danpost

2018/2/27

#
You have a type for the parameter of the method -- but no name for the parameter:
protected void addedToWorld(WorldSky worldSky)
Also, you can remove line 2 (imported with line 1).
You need to login to post a reply.