I've been trying to get an actor to perform the conditional that's within it's act section, however Greenfoot doesn't seem to want to run the code. I've triple checked it to make sure the syntax is at least correct and compiling it doesn't give any errors. It's just that when I run my program, Greenfoot just seems to ignore it. To test this I've written a code to print out 'test' if it reaches the area of the code where the conditional is located, and once again, Greenfoot ignores it. Putting the test code before the conditional works however.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class StatusBar1 here. * * @author (your name) * @version (a version number or a date) */ public class StatusBar1 extends Actor { /** * Act - do whatever the StatusBar1 wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ World world = getWorld(); public void act() { if (world instanceof BattleWorld || world instanceof AnswerCorrectWorld || world instanceof InvItemsNone) { getImage().setTransparency(0); } if (world instanceof BattleFight) { getImage().setTransparency(255); setImage("status-bar-inverted.png"); } if (world instanceof BattleWorld2) { getImage().setTransparency(0); } /* if (world instanceof AnswerCorrectWorld) { getImage().setTransparency(0); }*/ if (world instanceof GameWorldAfterBattle || world instanceof BattleFight2) { getImage().setTransparency(255); } /*if (world instanceof InvItemsNone) { getImage().setTransparency(0); } if (world instanceof BattleWorld2) { getImage().setTransparency(0); }*/ /* if (world instanceof BattleFight2) { getImage().setTransparency(255); }*/ } }