Below you will find my code for the world
And the method isClicked() doesn't seem it be working whatsoever. I click on the creditsButton, no error pops up, but colorOver() doesn't... you know... color over.
In case you want me to move isClicked() to my creditsButton actor, the reason I can't, is because I can't access 'this' from a non-static method (isClicked()), and if I make it a static, colorOver() can't be accessed because apparently getBackground() can't be used in a static method.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class MyWorld here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class mainMenu extends World
{
GreenfootImage bg;
GreenfootImage bgImage;
/**
* Constructor for objects of class MyWorld.
*
*/
public mainMenu()
{
super(1280, 800, 1);
colorOver();
addObjects();
}
public void colorOver(){
GreenfootImage bg = getBackground();
Color green = new Color(0, 175, 0);
for(int x = 320; x < 960; x++){
for(int y = 300; y < bg.getHeight(); y++){
bg.setColorAt(x, y, green);
}
}
}
public void isClicked(){
if(Greenfoot.mouseClicked(creditsButton.class)){
colorOver();
}
}
public void addObjects(){
bg = getBackground();
fire fire1 = new fire();
addObject(fire1, bg.getWidth()/2, 325);
fire fire2 = new fire();
addObject(fire2, fire1.getX() - 200, 325);
fire fire3 = new fire();
addObject(fire3, fire1.getX() + 200, 325);
startGameButton stBt = new startGameButton();
addObject(stBt, bg.getWidth()/2, 430);
upgradesButton ugBt = new upgradesButton();
addObject(ugBt, bg.getWidth()/2, 510);
optionsButton opBt = new optionsButton();
addObject(opBt, bg.getWidth()/2, 590);
creditsButton cdBt = new creditsButton();
addObject(cdBt, bg.getWidth()/2, 670);
}
}

