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

2016/4/16

Sound not playing?

xlRenn xlRenn

2016/4/16

#
Hi, I'm currently making a pursuit game. I have eating.wav in my sounds directory, and it should play whenever my crab eats the worm. I added it in my code under the Crab actor like this:
public void eat()
    {
        Actor worm;
        worm = getOneObjectAtOffset(0,0, Worm.class);
        if(worm != null)
        {
            World world;
            world = getWorld();
            counter.add(1);
            Greenfoot.playSound("eating.wav");
            wormsEaten ++;
            world.removeObject(worm);
            world.addObject(worm, Greenfoot.getRandomNumber(500), Greenfoot.getRandomNumber(500));
        }    
    
   }
It was working this morning, before I added in some extra things like a score counter and lives. Any idea why it isn't playing? Thanks!
danpost danpost

2016/4/16

#
There does not appear to be anything wrong with the code. Do other sounds work? have you checked your sound setting (volume and mute)?
You need to login to post a reply.