Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - TheRavenBlue

Pages: [1]
1
There's no reason to explicitly compare to bool literals, the values themselves are already true or false. Furthermore, explicitly writing the negated condition in the else branch is unnecessary and confusing.
    if (Bool.EnableMusic)
    {
        pMusic.play();
    }
    else
    {
        pMusic.stop();
    }

I tried to make that already and it did not work either but I will take a look into Jesper's Jukebox source and Ill return with an answer if I can get it to work or not!

2
Rewrite that if statement. You can't have if a == b || c, you need ( a == b || a == c ) , with the brackets in this case.

Thanks for pointing that out I did not see that!

3
it does not pause it when
EnableMusic == false

pMusic.stop();

For your information, an sf::Music object can supply you with information such as its current playing status. It can tell you if the music is currently playing, stopped or paused.
e.g.
if (music.getStatus() == sf::Music::Paused)
    music.play();
else
    music.pause();

Hm, okay thanks this could come in handy.
But it does not pause / stop the music it continues to play no matter what.
        if (Bool.EnableMusic = true && (pMusic.getStatus() == sf::Music::Stopped || pMusic.getStatus() == sf::Music::Paused))
                pMusic.play();
        else if (Bool.EnableMusic == false && pMusic.getStatus() == sf::Music::Playing)
                pMusic.pause();
Does the:
pMusic.setLoop(Loop);
have something to do with it not pausing or stopping?

4
The important thing here is that the actual sf::Music object is created outside of this function as is in existence for the entire time that the music is required so are you now creating "pMusic" elsewhere and keeping it alive?

Why is it called "pMusic"? What's wrong with "music"?

There is nothing wrong with "music" I just named it to something random to test it out!
But I'm having another problem, I want to toggle between
pMusic.pause();
and
pMusic.play();
this is how it looks like right now:
int MainMenyMusic::playMenyMusic(string FileLocation, float Volume, bool Loop)
{
        pMusic.setVolume(Volume);
        pMusic.setLoop(Loop);
        if (!pMusic.openFromFile(FileLocation))
        {
                MessageBox(NULL, "Missing files please re-download the game!", "Error", MB_OK);
                if (IDOK)
                {
                        exit(0);
                }
        }
        if (Bool.EnableMusic == true)
        {
                pMusic.play();
        }
        else if (Bool.EnableMusic == false)
        {
                pMusic.stop();
        }
        return 0;
}

It plays the music but it does not pause it when
EnableMusic == false
any ideas?

5
You are creating an sf::Music instance locally inside that method, opening the file, starting it to play, and then the instance gets destroyed as the method ends since it goes out of scope.

Thanks!
I got it working.

How I use it:
Music->playMenyMusic("Data//Music//MainMeny//MenySound.wav", 25, true);

My function:
int MainMenyMusic::playMenyMusic(string FileLocation, float Volume, bool Loop)
{
        pMusic.setVolume(Volume);
        pMusic.setLoop(Loop);
        if (!pMusic.openFromFile(FileLocation))
        {
                MessageBox(NULL, "Missing files please re-download the game!", "Error", MB_OK);
                if (IDOK)
                {
                        exit(0);
                }
        }
        pMusic.play();
        return 0;
}

6
if (music.openFromFile("test.wav") && !music.Playing)
        {
                music.play();
       
This opens the file and, if successful, starts to play it.

if (!music.openFromFile("test.wav"))
        {
                exit(0);
        }
This - immediately following the previous code - opens the file again (so any previously playing file will be stopped) and, if unsuccessful, closes the program.

Ah, okay thank you!
I edited my code so it looks like this now:
void MainMenyMusic::PlayMusic()
{
        sf::Music music;
        music.setVolume(100);
        if (!music.openFromFile("test.wav"))
        {
                exit(0);
        }
                music.play();
}

And the program starts but there is still no music.

7
Audio / Program loads .WAV but does not play it back an/or I cant hear it!
« on: December 16, 2015, 10:08:50 pm »
I'm creating a small game and I wanted my program to play music in the main meny this is how it looks like now:
void MainMenyMusic::PlayMusic()
{
        sf::Music music;
        music.setVolume(50);
        if (music.openFromFile("test.wav") && !music.Playing)
        {
                music.play();
        }

        if (!music.openFromFile("test.wav"))
        {
                exit(0);
        }
}

I know that it is not the best but I wanted to test it out I have also done exactly like the tutorial said about playing music but it did not work either.
What is wrong with this?
I'm also using DirectX to draw it all and using SFML to do some back end stuff as networking and sound!

Thanks!

8
General / Help setting up SFML with Code::Blocks on Ubuntu!
« on: November 26, 2015, 12:31:02 pm »
Hello, I'm having some problem setting up SFML on Code::Blocks on Ubuntu I tried to follow the Windows tutorial here but It did not work for me, can someone write or link me to a Linux & Code::Blocks specific tutorial!

Thank you!

Pages: [1]
anything