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

2021/2/18

Sound not working

AnJoMorto AnJoMorto

2021/2/18

#
I have an interactive title screen and was trying that when the player clicks on the character he says a random sentence, one of them being a rare EasterEgg. I got this code after initiating all the sounds with GreenfootSound a = new GreenfootSound("name.wav");
        if(Greenfoot.mousePressed(this))
        {
        
            int rn = Greenfoot.getRandomNumber(31)+1;
            
            if((rn >= 1)  && (rn <= 3)) {a.play();}
            if((rn >= 4)  && (rn <= 6)) {b.play();}
            if((rn >= 7)  && (rn <= 9)) {c.play();}
            if((rn >= 10) && (rn <= 12)){d.play();}
            if((rn >= 13) && (rn <= 15)){e.play();}
            if((rn >= 16) && (rn <= 18)){f.play();}
            if((rn >= 19) && (rn <= 21)){g.play();}
            if((rn >= 22) && (rn <= 24)){h.play();}
            if((rn >= 25) && (rn <= 27)){i.play();}
            if((rn >= 28) && (rn <= 30)){j.play();}
            if (rn == 31)               {ee.play();}
            
        }
After doing this, only the "ee" sound comes out 1/31 times and the rest of the time only silence comes out. Does anyone know why?
You need to login to post a reply.