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

2024/1/28

How to add a loop background sound that goes in multiple levels and stops when the character dies.

I3litz I3litz

2024/1/28

#
I need again help in my game, i need a background sound.
danpost danpost

2024/1/29

#
I3litz wrote...
I need again help in my game, i need a background sound.
/** *****      in MyWorld     ***** */
public static GreenfootSound bgSound = new GreenfootSound(/** arg */);

public void started() {
    bgSound.playLoop();
}

public void stopped() {
    bgSound.pause();
}

/** *****     in Player class     ***** */
// at end of act (assuming player is removed from world when it dies)
if (this.getWorld() == null) {
    MyWorld.bgSound.stop();
}
I3litz I3litz

2024/1/29

#
Thank you im gonna try it out.
You need to login to post a reply.