Hello, I want to play music when my player dies, I have this in Int main
int main()
{
Music death;
death.openFromFile("music/death.ogg");
and I want to put death.play(); here
while (window.isOpen())
{
float time = clock.getElapsedTime().asMicroseconds();
if (p.life == true) gameTime = gameTimeClock.getElapsedTime().asSeconds();
else {
p.sprite.setColor(Color(235, 65, 7));
view.zoom(0.999f);
view.move(0, 0.03);
view.move(0.03, 0);
}
but
if (p.life == true) gameTime = gameTimeClock.getElapsedTime().asSeconds();
else {
death.play();
wouldn't work... Can you please tell me what to do in details, because I'm just starting to learn programming.
Some details: Visual studio 2013, win 10, and I have class Player in my code.
wouldn't work
What does this mean? What does it do instead of what you expect it to do? Crash? Hear nothing? Error message?
Are you certain that the music file is opening correctly?
Remember to test the return value of openFromFile():
if (!death.openFromFile("music/death.ogg"))
{
std::cerr << "\"music/death.ogg\" could not be opened!" << std::endl;
return EXIT_FAILURE;
}