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

2018/1/27

If the player clicks on a class,then start the game with some parameters

frequency frequency

2018/1/27

#
Hello, This is the scenario http://www.greenfoot.org/scenarios/20750 I want when a player selects a class from the seconds,to create an new world and start playing. If we make it work,where will the games code be placed?On my world? Thanks!
danpost danpost

2018/1/27

#
You will have a Menu world and a Game world. The Menu world will have objects that can be clicked on.. These clickable objects should all be from the same generic Button type class and the Menu world should keep a reference to these objects, plus check and act on clicks on those objects. Game play codes go in the Game world.
frequency frequency

2018/1/27

#
Thanks,i made it. Now i need to find out where the hell should i put the code? For eg. If player clicks on the 1 option then , X,YX,Y,X,X, .You get it!
danpost danpost

2018/1/27

#
frequency wrote...
Thanks,i made it. Now i need to find out where the hell should i put the code? For eg. If player clicks on the 1 option then , X,YX,Y,X,X, .You get it!
Given here:
danpost wrote...
the Menu world should keep a reference to these objects, plus check and act on clicks on those objects.
frequency frequency

2018/1/27

#
So. i should add the following
if(Greenfoot.mouseClicked(this))
        {
            Greenfoot.setWorld(new MyWorld());
            getWorld().addObject(new Pressed(), 750, 400);
        }
        
To my actor,called thirty_seconds. It does not add the actor
danpost danpost

2018/1/27

#
frequency wrote...
So. i should add the following
if(Greenfoot.mouseClicked(this))
        {
            Greenfoot.setWorld(new MyWorld());
            getWorld().addObject(new Pressed(), 750, 400);
        }
        
To my actor,called thirty_seconds. It does not add the actor
I did not say anything about putting code in a button class and thirty_seconds would be a button class. Add the button from the constructor of the Menu class and check for clicks on the buttons from the act method of the Menu class.
frequency frequency

2018/1/28

#
I want to finish the scoreboard and timer first,since they are easier. If you want take a look to my other posts
You need to login to post a reply.