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

2021/3/11

No sound

Topben107 Topben107

2021/3/11

#
I'm doing a project for school, and I need some sound in it. I've followed my teacher's instructions, but no sound is coming out, but it does come out for his code. Here it is Greenfoot.playSound("popLow.wav"); Any advice would be appreciated.
danpost danpost

2021/3/11

#
Topben107 wrote...
no sound is coming out
Show what you tried.
Topben107 Topben107

2021/3/12

#
I'm not sure what you mean. but for clarification, this is an assignment I'm doing in school, where, for now, we just try our best to copy and understand what our teacher wrote. but before, I would get error messages saying it wouldn't work, but it still ran the program, my default audio player is windows media player, and that code is all that my teacher wrote. this is all for clarification in case it helps with any advice, thank you
danpost danpost

2021/3/12

#
Show the code you tried when no sound came out.
Topben107 Topben107

2021/3/12

#
that is the code
Topben107 Topben107

2021/3/12

#
this is the code Greenfoot.playSound("popLow.wav"); unless you mean this if (Afal!=null) { Cell world; world=(Cell)getWorld(); world.removeObject(Afal); Greenfoot.playSound("popLow.wav"); } "afal" is welsh for apple in case you want to know
danpost danpost

2021/3/12

#
Topben107 wrote...
unless you mean this if (Afal!=null) { Cell world; world=(Cell)getWorld(); world.removeObject(Afal); Greenfoot.playSound("popLow.wav"); }
What is the rest of the method (mainly before what is given here)?
Topben107 Topben107

2021/3/12

#
Actor Afal;
        Afal=getOneObjectAtOffset(0,0,Afal.class);
        if (Afal!=null)
        {
            Cell world;
            world=(Cell)getWorld();
            world.removeObject(Afal);
            Greenfoot.playSound("popLow.wav");
        }
its all this, and every thing before it is just the code for moving, this is the entire code for eating an apple, having the apple disappear, and then playing a sound
danpost danpost

2021/3/12

#
Topben107 wrote...
its all this, and every thing before it is just the code for moving, this is the entire code for eating an apple, having the apple disappear, and then playing a sound
I do not see anything out of sorts. Is this in the act method?
Topben107 Topben107

2021/3/12

#
whats the 'act method'?
danpost danpost

2021/3/12

#
Topben107 wrote...
whats the 'act method'?
If you have to ask that, I'm going to have to ask for the entire class' codes.
Topben107 Topben107

2021/3/12

#
everyone in the class is using the same code
danpost danpost

2021/3/13

#
Topben107 wrote...
everyone in the class is using the same code
Not that class -- the actor's class (shown in the editor).
mariq_rasyid29 mariq_rasyid29

2021/3/14

#
why not use after public class used
public Greenfoot.Sound <name_variable> = new Greenfoot.Sound("name_file");
then in public void act type
<name_variable>.play();
or
<name_variable>.playloop();
mariq_rasyid29 mariq_rasyid29

2021/3/14

#
mariq_rasyid29 wrote...
why not use after public class used
public Greenfoot.Sound <name_variable> = new Greenfoot.Sound("name_file");
then in public void act type
<name_variable>.play();
or
<name_variable>.playloop();
this is very work in my project
You need to login to post a reply.