This site requires JavaScript, please enable it in your browser!
Greenfoot back
MrGigglesII
MrGigglesII wrote ...

2015/4/1

HELP

MrGigglesII MrGigglesII

2015/4/1

#
What is the code to create a boolean that is recognizable in both the code for the world classes and actor classes? In other words I want a boolean that works in the an actor class and a world class.
danpost danpost

2015/4/1

#
MrGigglesII wrote...
What is the code to create a boolean that is recognizable in both the code for the world classes and actor classes? In other words I want a boolean that works in the an actor class and a world class.
How is the boolean defined and what it is used for?
MrGigglesII MrGigglesII

2015/4/1

#
If the boolean is true it means that the player has been eaten by the enemy. If the boolean is true, the world should switch to a different background. I also am wondering how to have a public integer that can be used in multiple places.
danpost danpost

2015/4/1

#
You can use the returned boolean value of 'getObjects(Player.class).isEmpty()' in the world class to determine if the player is in the world (you do not need a boolean field; just use that as the condition in an 'if' statement). How is the integer defined and what is it supposed to represent?
MrGigglesII MrGigglesII

2015/4/1

#
The int represents the amount of items the player has eaten. After it has eaten all of the objects in the world it should switch to another background. The into won't be used in any type of counter.
danpost danpost

2015/4/1

#
Again, you can probably use something similar to how the world determines if any player is in the world. For example, if the player is eating objects of the 'Food' class:
if (getObjects(Food.class).isEmpty())
{
    setBackground( ... );
    // whatever else you want to do at this point
}
The code can be used in the act method of the world.
MrGigglesII MrGigglesII

2015/4/1

#
Would I put that in the world class or actor class or somewhere else?
danpost danpost

2015/4/1

#
MrGigglesII wrote...
Would I put that in the world class or actor class or somewhere else?
Put it in the Object class -- where the Object class is a World class -- where the World class is a subclass of World.
Again, you can probably use something similar to how the world determines if any player is in the world. For example, if the player is eating objects of the 'Food' class:
if (getObjects(Food.class).isEmpty())
{
    setBackground( ... );
    // whatever else you want to do at this point
}
The code can be used in the act method of the world.
Did you read or look at any of this?
MrGigglesII MrGigglesII

2015/4/1

#
Sorry. Thanks for the help.
You need to login to post a reply.