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

2018/12/8

Stopping Background Music When One Actor Touches Another Actor

TyrantVal2542 TyrantVal2542

2018/12/8

#
I'm quite new to programming and I can usually find solutions on this website, but not really this one. So in my game I have background music playing and when it is Game Over, there is a new song. It is game over when the player class touches the enemy class. I'm trying to get the background music to stop and let the game over music play. I can post some code if necessary, but I'm just not sure what code to add.
Super_Hippo Super_Hippo

2018/12/8

#
Make sure you save a reference to the background music GreenfootSound object when creating it. Then, you can use the 'stop' method on it to stop the music. Do not use 'Greenfoot.playSound' for music.
danpost danpost

2018/12/8

#
TyrantVal2542 wrote...
in my game I have background music playing and when it is Game Over, there is a new song. It is game over when the player class touches the enemy class. I'm trying to get the background music to stop and let the game over music play.
I wrote a background music support class scenario called BGMusic Actor Class. The BGMusic class could be useful whether you need an actor object from the class or not.
You need to login to post a reply.