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

2015/12/19

How to have background game music carry over between worlds as a static variable?

16cruzs 16cruzs

2015/12/19

#
How to have background game music carry over between worlds as a static variable?
Super_Hippo Super_Hippo

2015/12/19

#
If it is static, it should be quite simple:
//in World1
public static GreenfootSound backgroundMusic = new GreenfootSound("nameOfTheFile.something");

//when starting
backgroundMusic.playLoop();
If you switch to World2, you can get a reference to the sound with 'World1.backgroundMusic'.
You need to login to post a reply.