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

2021/5/25

changing worlds by choices

bangtan bangtan

2021/5/25

#
I have 2 worlds cars and levels. Is it possible to show a new world when an actor from cars and levels has been clicked? The flow of the game is get to choose a car then get to choose a difficulty of the game. How can i call the next world based on what the player has chosen on the car and the difficulty? suppose that they chose car a (cara) and then chose easy mode, how could i call the next world based on the players choice like car a and easy. the class below is on actor easy. i have only tried this but wont work

if (Greenfoot.mouseClicked(cara, this))
        {
            Greenfoot.setWorld(new problem());
        }
RcCookie RcCookie

2021/5/25

#
The code above does exactly what you are trying to achieve - but there is a different error. Greenfoot.mouseClicked() expects only a single object. If you want either of the passed objects to trigger the if statement, you can use
if(Greenfoot.mouseClicked(cara) || Greenfoot.mouseClicked(this)) { // ...
danpost danpost

2021/5/25

#
RcCookie wrote...
If you want either of the passed objects to trigger the if statement, you can use
if(Greenfoot.mouseClicked(cara) || Greenfoot.mouseClicked(this)) { // ...
But, that is not what is wanted. That is, not one or the other choice is to be made, but both. To achieve that, neither choosing can trigger the problem world. A separate button actor should be used for that. One of each set of choices can be pre-selected and the user can change the selection at will. When satisfied, the user can click the "Done" or "Proceed" (or whatever) button.
You need to login to post a reply.