So I've been racking my brain trying to figure out how to do this and/or why the hell this won't work. I basically want to, upon the act loop running, change the background from one background to another. I figured something like this would work:
public void switchBG() {
World world1 = getWorld();
Greenfootimage bg1 = new GreenfootImage("blah.jpg");
Greenfootimage bg2 = new GreenfootImage("blah2.jpg");
if (world1.getBackground() == bg1)
{
world1.setBackground(bg2);
}
else
{
world1.setBackground(bg1);
}
}
Any tips? I'm probably missing something completely obvious so apologies for my terrible coding skills.
Thanks!
RV