SetSound
This function sets the sound a source will play.
Syntax
- void SetSound(Sound* sound)
Parameters
Remarks
This function will increment the reference count of the new sound and decrement the reference count of the old sound (if they exist).
Example
#include "Leadwerks.h"
using namespace Leadwerks;
Source* source = NULL;
int main(int argc, const char *argv[])
{
Leadwerks::Window* window = Leadwerks::Window::Create();
Context* context = Context::Create(window);
//Load a sound
Sound* sound = Sound::Load("Sound/Music/menutheme.wav");
source = Source::Create();
source->SetSound(sound);
sound->Release();
source->SetLoopMode(true);
source->Play();
while (true)
{
//Press space key to pause/resume sound
if (window->KeyHit(Key::Space))
{
if (source->GetState() == Source::Paused)
{
source->Resume();
}
else
{
source->Pause();
}
}
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
Leadwerks::Time::Update();
context->SetColor(0, 0, 0, 0);
context->Clear();
context->Sync();
}
return 0;
}