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.


Topics - sima

Pages: [1]
1
Audio / SFML no sound playing with soundbuffers stored in ResourceHolder
« on: November 06, 2021, 03:18:06 pm »
Hi,

i'm currently working on a small game with sfml.

For resource loading and holding i'm using the ResourceHolder described in the SFML Game
Development Book: https://github.com/SFML/SFML-Game-Development-Book/blob/master/02_Resources/Include/Book/ResourceHolder.hpp

Inside a SoundManager class i'm loading different sounds to this ResourceHolder. This SoundManager has a playSound function when i want to play a sound.

    void SoundManager::playSound(SoundType soundToPlay) {
        auto buffer = sounds.get(soundToPlay);
        auto sound = sf::Sound(buffer);
        sound.play();
    }

but i don't hear any sounds. Do i have to store different sound objects for every sound in a map? I also tried to use a sf::Sound object as a class member, but this also didn't worked.

Using this ResourceHolder my textures are loaded correctly.

Thank you for you help

Pages: [1]