I'm already using sf::Music to play a streamed background song in my game and it works well. For some reason I can't play any sound effects trough sf::Sound.
Here's a sample of different classes :
Resource Manager(RM) is a singleton holding a SoundBuffer member :
sf::SoundBuffer& RM::hitSoundBuffer()
{
return _hitSound;
}
RM::RM(void) :
SPLASH_SCREEN_PATH("res/texture.png"),
START_BUTTON_PATH("res/play.png"),
BOARD_PATH("res/board.png"),
BLOCKS_PATH("res/blockColors.png"),
PLAYSTATE_BG("res/playstate_wallpaper.png"),
MUSIC_BG("res/bgMusic.ogg"),
SOUND_HIT("res/hit.ogg")
{
_splashScreenTexture.loadFromFile(SPLASH_SCREEN_PATH);
_startButtonTexture.loadFromFile(START_BUTTON_PATH);
_boardTexture.loadFromFile(BOARD_PATH);
_blocksTexture.loadFromFile(BLOCKS_PATH);
_playStateBG.loadFromFile(PLAYSTATE_BG);
_bgMusic.setLoop(true);
_bgMusic.setVolume(50.0f);
_bgMusic.openFromFile(MUSIC_BG);
_hitSound.loadFromFile(SOUND_HIT);
}
Here's where I call it :
bool canMoveDown = _gameGrid.attemptPeriodicShapeMoveDown(_droppingShape);
if(!canMoveDown)
{
//Once we put the shape down we,
//-Delete the falling shape since it's imprinted in the grid.
//-We possibly clear filled rows by the player.
//-We check for a loss.
//-Sound on hit.
delete _droppingShape;
_droppingShape = NULL;
sf::Sound hitSound(RM::getInstance()->hitSoundBuffer());
hitSound.play();
_gameGrid.possiblyClearRows();
_gameOver = _gameGrid.checkForLoss();
}
No idea why I'm not hearing a sound. I tried swapping audio files to no avail. This is 2.0 in VS.