Hi, I am a new at programming.. I hope you can help such simple questions
Oh well we all gotta start somewhere.
I know this isn't working.. and IU have tried many other thigns. this code is ment to explain what I want to do with it or how I think it should work...
#ifndef SFX_H
#define SFX_H
#include <SFML/Audio.hpp>
#include "GeneralHeaders.h"
class sfx{
sf::Sound sfxERROR;
sf::Sound sxfHIT;
sf::SoundBuffer Buffer;
public:
sfx();
void sError();
void sHit();
};
#endif
#include "sfx.h"
using namespace std;
using namespace sf;
sfx::sfx(){
if (!Buffer.LoadFromFile("Resource/Sound/error.ogg"))
{
cout << "File not Found - Press enter to Continue..." << endl;
cin.ignore(10000, '\n');
}
sfxERROR.GetBuffer(Buffer);
if (!Buffer.LoadFromFile("Resource/Sound/hit.ogg.ogg"))
{
cout << "File not Found - Press enter to Continue..." << endl;
cin.ignore(10000, '\n');
}
sfxHIT.GetBuffer(Buffer);
}
void sfx::sError()
{
sfxERROR.Play();
}
void sfx::sHit()
{
sxfHIT.Play();
}
int main(){
sfx SoundTest;
SountTest.sError();
SoundTest.sHit();
cin.ignore(10000, '\n');
}
Thanks in advance... I would also like ot be able to call this object global some how so I can call a soudn from anywhere in my progrema....
The idea is to have a class, and the constructor load into a variable all the sounds I need, and then have a simple way to play them from anywhere...
Am i completely about his wrong.. suggestions would help..
basically I have a game it is pretty simple and just want to add spots to play sounds..