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

2019/11/14

Problem about BGM

MianBao_Bread MianBao_Bread

2019/11/14

#
I want add bgm in my game. I'm trying 2 code
public void act() {
        Greenfoot.playSound("bgm.wav");
    }
and
GreenfootSound backgroundMusic = new GreenfootSound("bgm.wav");
public void act() {
        backgroundMusic.playLoop();
    }
They both can't work, how to solve it.
danpost danpost

2019/11/14

#
MianBao_Bread wrote...
I want add bgm in my game. I'm trying 2 code << Code Set #1 Omitted >> and << Code Set #2 Omitted >> They both can't work, how to solve it.
Code set #1 will continuously create a new GreenfootSound object and play them on top of each other (multiple instances of sound). Code set #2 should work okay. Are you getting an error message? And if so, what is the message?
ITStudent ITStudent

2019/11/16

#
Code 1 : U can use GreenfootSound bgm = new GreenfootSound("bgm.wav"); if(!bgm.isPlaying()){bgm.play();} Code 2 should work fine! Afterall i have a SoundProblem too (see Discussions)
You need to login to post a reply.