so, the problem is, some sounds are played and some are not...
it is regarding to my project which is also here in this forum:
http://en.sfml-dev.org/forums/index.php?topic=13453.0if you get the release and play it, you will notice that:
if a big cow is spawning there is no sound
if you get the third weapon there is no sound
if the third boss dies there is no sound
every other sound works
here my code for the sound:
//IngameSfx.h
#ifndef INGAMESFX_H
#define INGAMESFX_H
#include <SFML/Audio.hpp>
#include <string>
class IngameSound
{
public:
void LoadSoundBuffer();
void setBuffer(int &volume);
void PlaySound(std::string sound);
private:
sf::SoundBuffer bossDeathBuffer;
sf::SoundBuffer bulletShotBuffer;
sf::SoundBuffer enemyCollisionBuffer;
sf::SoundBuffer healthDropBuffer;
sf::SoundBuffer playerCollisionBuffer;
sf::SoundBuffer playerDeathBuffer;
sf::SoundBuffer monkeyFartBuffer;
sf::SoundBuffer pewBuffer;
sf::SoundBuffer boss1HitBuffer;
sf::SoundBuffer cowBuffer;
sf::SoundBuffer boss3spawn;
sf::SoundBuffer boss3death;
sf::Sound bossDeathSound;
sf::Sound bulletShotSound;
sf::Sound enemyCollisionSound;
sf::Sound healthDropSound;
sf::Sound playerCollisionSound;
sf::Sound playerDeathSound;
sf::Sound monkeyFartSound;
sf::Sound pewSound;
sf::Sound boss1HitSound;
sf::Sound cowSound;
sf::Sound boss3spawnSound;
sf::Sound boss3deathSound;
};
#endif
//IngameSfx.cpp
#include "IngameSfx.h"
//Sound
void IngameSound::LoadSoundBuffer()
{
bossDeathBuffer.loadFromFile("audio//bossDeath.ogg");
bulletShotBuffer.loadFromFile("audio//bulletShot.ogg");
enemyCollisionBuffer.loadFromFile("audio//enemyCollision.ogg");
healthDropBuffer.loadFromFile("audio//healthDrop.ogg");
playerCollisionBuffer.loadFromFile("audio//playerCollision.ogg");
playerDeathBuffer.loadFromFile("audio//playerDeath.ogg");
monkeyFartBuffer.loadFromFile("audio//fart.ogg");
pewBuffer.loadFromFile("audio//pew.ogg");
boss1HitBuffer.loadFromFile("audio//boss1hit.ogg");
cowBuffer.loadFromFile("audio//cow.ogg");
boss3spawn.loadFromFile("audio//boss3spawn.ogg");
boss3death.loadFromFile("audio//boss3death.ogg");
}
void IngameSound::setBuffer(int &volume)
{
bossDeathSound.setBuffer(bossDeathBuffer);
bossDeathSound.setVolume(volume);
bulletShotSound.setBuffer(bulletShotBuffer);
bulletShotSound.setVolume(volume);
enemyCollisionSound.setBuffer(enemyCollisionBuffer);
enemyCollisionSound.setVolume(volume);
healthDropSound.setBuffer(healthDropBuffer);
healthDropSound.setVolume(volume);
playerCollisionSound.setBuffer(playerCollisionBuffer);
playerCollisionSound.setVolume(volume);
playerDeathSound.setBuffer(playerDeathBuffer);
playerDeathSound.setVolume(volume);
monkeyFartSound.setBuffer(monkeyFartBuffer);
monkeyFartSound.setVolume(volume);
pewSound.setBuffer(pewBuffer);
pewSound.setVolume(volume);
boss1HitSound.setBuffer(boss1HitBuffer);
boss1HitSound.setVolume(volume);
cowSound.setBuffer(cowBuffer);
cowSound.setVolume(volume);
boss3spawnSound.setBuffer(boss3spawn);
boss3spawnSound.setVolume(volume);
boss3deathSound.setBuffer(boss3death);
boss3deathSound.setVolume(volume);
}
void IngameSound::PlaySound(std::string sound)
{
if (sound == "bulletShot")
{
bulletShotSound.play();
}
if (sound == "fart")
{
monkeyFartSound.play();
}
if (sound == "enemyCollision")
{
enemyCollisionSound.play();
}
if (sound == "playerCollision")
{
playerCollisionSound.play();
}
if (sound == "bossDeath")
{
bossDeathSound.play();
}
if (sound == "healthDrop")
{
healthDropSound.play();
}
if (sound == "playerDeath")
{
playerDeathSound.play();
}
if (sound == "pew")
{
pewSound.play();
}
if (sound == "boss1Hit")
{
boss1HitSound.play();
}
if (sound == "cow")
{
cowSound.play();
}
if (sound == "boss3spawn")
{
boss3spawnSound.play();
}
if (sound == "boss3death")
{
boss3deathSound.play();
}
}
the sound is used in several classes. here some example:
works
void UpdateManager::BulletSpawn(int &counter, std::vector<Bullet> &vector, HighscoreManager &highscore, WeaponManager &weapon, Player &player, IngameSound &sound)
{
if (counter >= 175 && weapon.bulletA)
{
Bullet bulletx;
highscore.setShotsFired(1);
bulletx.SetPosition(player.getPosition().x - 4, player.getPosition().y);
vector.push_back(bulletx);
sound.PlaySound("bulletShot");
counter = 0;
}
}
does not work
void UpdateManager::PewSpawn(std::vector<Pew> &vector, HighscoreManager &highscore, WeaponManager &weapon, Player &player, IngameSound &sound, bool &pewOnCooldown)
{
if (weapon.pewA && !pewOnCooldown)
{
Pew pewx;
highscore.setShotsFired(1);
pewx.SetPosition(player.getPosition().x - 4, player.getPosition().y);
vector.push_back(pewx);
sound.PlaySound("pew");
pewOnCooldown = true;
}
}
maybe it has something to deal with the files?
if you get the release the files are all included.
thanks for any help