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

2013/7/12

i am trying to stop my music from my 1st world with my 5th world. what am i doing wrong??

1
2
qsapp.3 qsapp.3

2013/7/13

#
and what do i put in the other worlds??
qsapp.3 qsapp.3

2013/7/13

#
and what do i put in the other worlds?
Gevater_Tod4711 Gevater_Tod4711

2013/7/13

#
Sorry I mixed up some different names for the GreenfootSound object. If you change the method in lines 25 to 27 into this mehtod:
public GreenfootSound getBgMusic() {
    return bgMusic;
}
It should work. But you need to declare the variable private GreenfootSound ... in all world classes. Not only in level5.
danpost danpost

2013/7/13

#
A much simpler solution is to make the GreenfootSound field in the Cover class 'static'.
private static GreenfootSound bgMusic = new GreenfootSound("Track 02.wav");
Then the method to stop the sound in the Cover class would be:
public static void stopBackgroundMusic()
{
    bgMusic.stop();
}
With this, you do not have to pass anything from level to level. Just start the loop in the Cover class and use the following in the Level5 constructor to stop the loop:
Cover.stopBackgroundMusic();
You need to login to post a reply.
1
2