SetPosition

This function sets a source's position in global space.

Syntax

Parameters

Remarks

Only sounds in mono format can be played with 3D spatialization. Stereo sounds will not be affected.

Example

position = Vec3(0,0,1)
--Create a window
window = Window:Create()
context = Context:Create(window)

--Load a sound
local sound = Sound:Load("Sound/Music/menutheme.wav")

--Create a source
source = Source:Create()
source:SetSound(sound)
sound:Release()
source:SetLoopMode(true)
source:Play()

--Create a listener
local listener = Listener:Create()

while true do
--Press left/right keys to move the source
if (window:KeyDown(Key.Right))then position.x = position.x + Time:GetSpeed()*0.1 end
if (window:KeyDown(Key.Left))then position.x = position.x - Time:GetSpeed()*0.1 end

source:SetPosition(position)

if window:Closed() or window:KeyHit(Key.Escape) then return false end

Time:Update()
context:SetColor(0,0,0)
context:Clear()

context:SetColor(1,1,1)
context:SetBlendMode(Blend.Alpha)
context:DrawText("Position: "..position:ToString(),2,2)

context:Sync()

end