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

2022/10/22

I wanna exchange Variables between my World subclass and actor subclass

N8TH1N6 N8TH1N6

2022/10/22

#
I wanna make a two player selection and then get a true or false value if the button is clicked to know which values are needed(the one or two player values). When I get the values the lobster checks if two or one player is activated and it need to delete both objects before giving a loose screen.
danpost danpost

2022/10/22

#
N8TH1N6 wrote...
I wanna make a two player selection and then get a true or false value if the button is clicked to know which values are needed(the one or two player values). When I get the values the lobster checks if two or one player is activated and it need to delete both objects before giving a loose screen.
It should not matter how many players there are. The lobster only needs to know if any are in the world at any time: So, in lobster class:, you can use the following condition (asking if any players are in the world):
if ( ! getWorld().getObjects(Player.class).isEmpty() )
Or, in world act method, you can do something like this:
if (getObjects(Player.class).isEmpty()) Greenfoot.stop();
(stopping is just one thing that you could do here; you can load the "You Lose" screen there as well, assuming it is of a different world). Even with the "You Lose" screen as an actor, in lobster, you could use the following:
if (getWorld().getObjects(GameOver.class).isEmpty())
(the world determines game over, -- no players in world -- and the lobster checks for the game over actor)
N8TH1N6 N8TH1N6

2022/10/22

#
danpost wrote...
N8TH1N6 wrote...
I wanna make a two player selection and then get a true or false value if the button is clicked to know which values are needed(the one or two player values). When I get the values the lobster checks if two or one player is activated and it need to delete both objects before giving a loose screen.
It should not matter how many players there are. The lobster only needs to know if any are in the world at any time: So, in lobster class:, you can use the following condition (asking if any players are in the world):
if ( ! getWorld().getObjects(Player.class).isEmpty() )
Or, in world act method, you can do something like this:
if (getObjects(Player.class).isEmpty()) Greenfoot.stop();
(stopping is just one thing that you could do here; you can load the "You Lose" screen there as well, assuming it is of a different world). Even with the "You Lose" screen as an actor, in lobster, you could use the following:
if (getWorld().getObjects(GameOver.class).isEmpty())
(the world determines game over, -- no players in world -- and the lobster checks for the game over actor)
Hey thanks for the answer but now it instally give me the end screen, the world didnt even load an I instant got the death screen
N8TH1N6 N8TH1N6

2022/10/22

#
Also, I have a selection screen with one and two player, and it should only check for both when I clicked on the two player button and then load the two player world
N8TH1N6 N8TH1N6

2022/10/22

#
Ok I found the error myself in your line
if ( ! getWorld().getObjects(Player.class).isEmpty() )
the ! made the error Thanks for the help : ) without you I wouldnt be able to get two player workin
You need to login to post a reply.