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

2016/12/27

World problem

Hondrok Hondrok

2016/12/27

#
Sooo... when I try to make the label accesible to the ball it give me a error at "new Dolphin(label);"
import greenfoot.*;

public class MyWorld extends World
{
    public MyWorld()
    {
        super(1500, 730, 1); 
        Dolphin dolphin = new Dolphin(label);
        Ground ground = new Ground();
        Label label = new Label("C O U N T : 0");
        
        addObject(dolphin,/**x*/64, /**y*/689);
        addObject(ground, 538, 722);    
        addObject(label, 150, 150);
    }
}
Super_Hippo Super_Hippo

2016/12/27

#
You can't use 'label' before the variable is created. Line 8 should be after line 10.
Hondrok Hondrok

2016/12/27

#
Super_Hippo wrote...
You can't use 'label' before the variable is created. Line 8 should be after line 10.
Thaaank you forgot that indentation matters in Java
You need to login to post a reply.