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

2018/5/9

Change Background

Cmo Cmo

2018/5/9

#
i need help changing the background of the game when the score reaches a certain amount.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public class Rocket extends Actor
{
    int score = 0;
    /**
     * Act - do whatever the Rocket wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act()
    {
        setLocation(getX(),getY()-20);
        addScore();
        checktop();
        if (score ==5)
        {
            getWorld().setBackground(new GreenfootImage("brick.jpg"));
        }
    }
danpost danpost

2018/5/9

#
Cmo wrote...
i need help changing the background of the game when the score reaches a certain amount. << Code Omitted
Please show your addScore method in your Rocket class.
You need to login to post a reply.