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 - Baig

Pages: [1]
1
Thank you so much  Laurent! it worked. Thanks again for guiding me :)

2
Can you please guide me where should i use fail.play(). i am stuck with it. No idea how to proceed.

3
Hi every one.
i am making a game in which i wanna use both sound and music. sound and music initialization is fine, no errors in loading etc. when ball does not hit the paddle, game over. in loop (of touching ball with paddle) i have put sound, which works fine. when game gets over, i wanna play a music too.

please guide me where to put that music. i don't want it to play in whole game, but just when the game gets over.

here is the code i have made so far.

    // Hit_Sound
        SoundBuffer hit_buffer;
        Sound hit;
        hit_buffer.loadFromFile("hit_sound.wav");
        hit.setBuffer(hit_buffer);

    // Fail_Music
        Music fail;
        fail.openFromFile("fail.ogg");
       
        while (window.isOpen())
        {

        // If does not collide with paddle then,
                else if (ball_bound.top >= 400)
                {
                        // fail.play();
                        state = 4;
                }
 
        window.clear();

        switch (state)
                {

        // game lost
                case 4:
                        window.draw(fail_1);
                        window.draw(fail_2);
         // fail.play();
                        }
               
        window.display();
}

i have tried fail.play, where i thought it would work. i have put it in comments for now. it does play but not continuous. listening to it feels like a very short part of it is playing again and again.

Please guide me where i am making mistake.



Pages: [1]