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

2017/12/13

How to get method from another world

Arifwc Arifwc

2017/12/13

#
I have world called "Menu" and "TetrisWorld". In World Menu I have method called started() to play sound. This sound play in the first time I run the greenfoot, but this sound never played after gameover in TetrisWorld. How can I fix this? P.S : Sorry for bad english
danpost danpost

2017/12/13

#
I guess one way is to go through a Menu world to start a new TetrisWorld world by utilizing a second Menu world constructor. Something like this:
public Menu(boolean restart)
{
    started();
    Greenfoot.setWorld(new TetrisWorld());
}
Then, instead of going directly to a new TetrisWorld at restart, go to a Menu world with this:
Greenfoot.setWorld(new Menu(true));
You need to login to post a reply.