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

2017/10/24

i can't get my background music to stop playing after i pause the game

1
2
darkenders darkenders

2017/10/24

#
hello, i can't get my background music to stop playing after i pause the game?
danpost danpost

2017/10/24

#
Cannot help without seeing what code you have Show class code where you create/start the music and where you try to stop it.
darkenders darkenders

2017/10/24

#
import greenfoot.*; // class declaration statement public class myWorld extends World // *** end class header *** // *** begin class code *** { // field declaration statement(s) GreenfootSound backgroundMusic = new GreenfootSound("circles.mp3"); // *** begin instance object constructor(s) *** public myWorld() { super(600, 400, 1); backgroundMusic.playLoop(); // etc. prepare(); }
darkenders darkenders

2017/10/24

#
there it is
danpost danpost

2017/10/25

#
You should be able to pause the background music when the scenario is paused. Make use of the 'stopped' method in the World class.
darkenders darkenders

2017/10/25

#
sorry, i'm just starting in Greenfoot so could you show me what the 'stopped' method is?
danpost danpost

2017/10/25

#
darkenders wrote...
sorry, i'm just starting in Greenfoot so could you show me what the 'stopped' method is?
You can find it here in the World class API documentation.
darkenders darkenders

2017/10/25

#
i tried it and it did not work?
darkenders darkenders

2017/10/25

#
wait i'm going to try again.
darkenders darkenders

2017/10/25

#
nope didn't work.
danpost danpost

2017/10/25

#
darkenders wrote...
nope didn't work.
Show what you tried?
darkenders darkenders

2017/10/25

#
// class declaration statement public class myWorld extends World // *** end class header *** // *** begin class code *** { // field declaration statement(s) GreenfootSound backgroundMusic = new GreenfootSound("circles.mp3"); // *** begin instance object constructor(s) *** public myWorld() { super(600, 400, 1); backgroundMusic.playLoop(); // etc. public void stopped() prepare(); }
danpost danpost

2017/10/25

#
The method does not go in the constructor. It goes outside of it and has a block of code of its own (like the 'prepare' method) where you need to implement the stopping of the music.
darkenders darkenders

2017/10/25

#
so like this public class myWorld extends World // *** end class header *** // *** begin class code *** { // field declaration statement(s) GreenfootSound backgroundMusic = new GreenfootSound("circles.mp3"); // *** begin instance object constructor(s) *** public myWorld() { super(600, 400, 1); backgroundMusic.playLoop(); // etc. prepare(); } public void stopped()
danpost danpost

2017/10/25

#
Okay, you have a method declaration line; but it still need a block of code to go with it.
There are more replies on the next page.
1
2