Hi again community, i've got another noob-question for you
This time i'm trying to pass a boolean value from a superclass to one of its subclasses, through tests with Greenfoot.stop(); I've concluded that the program runs the boolean in the superclass and returns true, but when i try to fetch it in my subclass it simply doesn't work (either the boolean isn't true anymore or something of that nature, because the program doesn't start the if-statement that i want it to.) Here's some of my code :
The code posted above is in my superclass and i've set it in a superclass because the player is supposed to run in to a blob which makes other objects physical. So when the player touches the blob the method is supposed to return true which would activate a series of other methods in it's subclasses such as the following code :
So my question is hopefully obvious ; what am I doing wrong? do I have to create some kind of reference to my superclass to be able to fetch the result from the boolean or .. ? If this is what I have to do, whould someone be kind enough to supply me with atleast a hint of what it should look like, so far I've only seen references to the world class and I haven't really figured out what a non-world reference should look like :p
Why does the code compile if the above is true, the code obviously recognizes the method and so on.. ?
Thanks in advance <3
Nubbit
public boolean checkTouchedBlob() //this is from the Superclass
{
boolean isActive = false;
if(isTouching(GreenBlobb.class))
{
isActive = true;
}
if(isTouching(BlueBlobb.class))
{
isActive = true;
}
return isActive;
}
@Override
public void act() //this is the subclass :)
{
if(checkTouchedBlob()==true)
// i've also tested: if(checkTouchedBlob()) (i don't know if it's a difference between the two)
{
activateBrick();
}
}
public void activateBrick()
{
Platform platform = new GreenPlatform();
getImage().setTransparency(255);
getWorld().getObjects(GreenBrick.class);
getWorld().addObject(platform, getX(), getY());
getWorld().removeObject(this);
}
