Hello, I hope you all are having a good day. I am trying to work on a guitar hero project for school and I was using the setWorld() method to change worlds when a button is pressed, but after I add a third setWorld() it breaks so I am now trying to make it so when a button is pressed the background is changed and then the world checks if the background is equal to that image then removes the buttons on the previous screen and adds a new button for the new screen.
(I am using Greenfoot 3.5.1)
This is my code:
I have tried many things but the if statement does not seem to even check if the background has changed.
public Start()
{
super(613, 502, 1);
}
public void act()
{
StartButton star = new StartButton(new MyWorld());
ControlButton y = new ControlButton();
GreenfootImage img = new GreenfootImage("StartScreen.png");
GreenfootImage con = new GreenfootImage("Controls.png");
if(getBackground() == img)
{
addObject(star,151, getHeight()/2);
addObject(y, 151, 350);
if(getBackground() == con)
{
BackToMenu k = new BackToMenu();
addObject(k, 470, 445);
removeObject(star);
removeObject(k);
if(Greenfoot.mouseClicked(k))
{
setBackground("StartScreen.png");
if(getBackground() == img)
{
removeObject(k);
}
}
}
}
}

