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

2017/4/21

Trying to make a counter

Ian_Neef Ian_Neef

2017/4/21

#
Trying to figure this out, been looking at tutorials and past discussions but it's lead me nowhere. This is my world's code.
public class Floor extends World
{
    private Scoreboard sb;
    /**
     * Constructor for objects of class Floor.
     * 
     */
    public Floor()
    {    
        super(600, 400, 1); 
        sb = new Scoreboard();
        addObject (sb,70,30);
    }
    
    public void updateScore()
    {
        sb.changeScore();
    }
}
Now I want to to have an actor, in this case a spider eat an ant, which will result in the score going up by one.
Super_Hippo Super_Hippo

2017/4/21

#
Use this line when the spider eats an ant.
((Floor) getWorld()).updateScore();
Ian_Neef Ian_Neef

2017/4/21

#
Super_Hippo wrote...
Use this line when the spider eats an ant.
((Floor) getWorld()).updateScore();
When I add this, I get the error "not a statement" and "; expected".
Super_Hippo Super_Hippo

2017/4/21

#
Where/how did you add it?
That's right super hippo u don't know shit
You need to login to post a reply.