I'm having issues with XRSound. I'm initialising it in clbkPostCreation like so:
Code:void Glider::clbkPostCreation() { XRSound *CreateInstance(VESSEL *pVessel); }
But when I ask it to play a sound, like this:
I get "a nonstatic member reference must be relative to a specific object".Code:XRSound::PlayWav(10037, true, 1.0);
How do I fix this?
You should learn more about pointers and classes in C++.
You need a private field in your class that holds the XRSound instance pointer. Let's say it is called "sound". You'd declare it in your class header:
Code:
#include "XRSound.h"
class Glider: public VESSEL4 {
...
private:
XRSound *sound;
}
Then you assign the new instance pointer to this field like so:
Code:
void Glider::clbkPostCreation()
{
sound = XRSound::CreateInstance(this);
}
To play sound, you have to dereference the pointer in the sound field like so:
Code:
sound->PlayWav(10037, true, 1.0);
In the destructor, you do this to clean up memory:
Code:
delete sound;