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

2014/2/9

Greenfoot Game Menu

crimsonred crimsonred

2014/2/9

#
Yes I know, there are demos, and there are other discussions, but I saw all those and tried everything I can, but whenever I click a button in my world, it doesn't go to the next world or something. My buttons are also images, not made of rectangles and text made in greenfoot. I also tried to add in the world, and even the button. public void act() { if (Greenfoot.mouseClicked(storybutton.class)) { Greenfoot.setWorld(new story()); } }
danpost danpost

2014/2/9

#
If this code is in the class that created the button, then try 'this':
1
2
3
4
5
6
7
public void act()
{
    if (Greenfoot.mouseClicked(this))
    {
        Greenfoot.setWorld(new story());
    }
}
crimsonred crimsonred

2014/2/9

#
what do you mean by "class that created the button btw? But I did try it but nothing happens, unless I put the code in the wrong class. THanks for the reply! Here's how it looks like: I tried putting that code in storybutton and in story class
danpost danpost

2014/2/9

#
It should go in the storybutton class. Make sure your buttons class has an empty act method in it.
crimsonred crimsonred

2014/2/9

#
thank you so much!
crimsonred crimsonred

2014/2/9

#
I decided to put a home button in the story world, but I can't seem to save the world so that if I reset it and go to story world, the home button will still be there
danpost danpost

2014/2/9

#
Right click on the story world icon and select 'new story()'. Then, add the button and save the world. Finally, right click on the world (as before) that is to be the first running world of your project and select 'new ...'. Manually creating a world sets that class as the one that creates the first active world of your project.
crimsonred crimsonred

2014/2/9

#
I get how it works now! thank you very much!
You need to login to post a reply.