neeamus neeamus - 5 months ago 49
Android Question

Monogame - Music and sound effect not playing simultaneously

I understand this question has been asked before but I'm doing it through Mono game and the programming language I'm using is C#.

I'm made a game that the aim of it is to go through obstacles and for every obstacle you go through, you earn a point. Now, I'm trying to add the finishing touches. I've added back ground music to the game but I want a sound to play every time you press the space bar. So i added the sound into the game and i put it through the pipeline tool, implemented the sound into the code and so on.

But every time I play the game, the BGM plays but if you press the space bar the sound plays but the BGM stops. I tried to add the sound as a 'sound effect' but its still playing it simultaneously.

This is where the sound gets loaded into the game.

Song backgroundMusic;
Song jumpsound;

This is the part of the code that plays the sound if you press the space bar.

public void Update (KeyboardState spaceNow, KeyboardState spacePrev,Song Jsound)
if((spaceNow.IsKeyDown(Keys.Space) == true) && (spacePrev.IsKeyDown(Keys.Space) == false))
y -= 50;
Vertspeed = -10;


Open to suggestions and feedback :)


Answer Source

Is there any reason why the jumpsound should be Song? It seems like you should use SoundEffect class instead.

It's also possible to play multiple soundeffects simultaneously.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download