Skip to content

Commit dcb20c6

Browse files
committed
se pan test
1 parent b3b3833 commit dcb20c6

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

data/test/scripts/test/audio/SoundEffect.lua

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,42 @@
11
local test = require("test")
22
local imgui = require("imgui")
33

4+
local SE_NAME = "啊!"
5+
46
---@class test.audio.SoundEffect : test.Base
57
local M = {}
68

79
function M:onCreate()
810
local old = lstg.GetResourceStatus()
911
lstg.SetResourceStatus("global")
10-
lstg.LoadSound("啊!", "res/audio/啊!.wav")
12+
lstg.LoadSound(SE_NAME, "res/audio/啊!.wav")
1113
lstg.SetResourceStatus(old)
14+
self.vol = 1.0
15+
self.pan = 0.0
1216
end
1317

1418
function M:onDestroy()
15-
lstg.RemoveResource("global", 5, "啊!")
19+
lstg.RemoveResource("global", 5, SE_NAME)
1620
end
1721

1822
function M:onUpdate()
1923
---@diagnostic disable-next-line: undefined-field
2024
local ImGui = imgui.ImGui
2125
if ImGui.Begin("Audio: Sound Effect") then
22-
ImGui.Text(("SE State: %s"):format(lstg.GetSoundState("啊!")))
26+
ImGui.Text(("SE State: %s"):format(lstg.GetSoundState(SE_NAME)))
27+
_, self.vol = ImGui.SliderFloat("Volume", self.vol, 0.0, 1.0)
28+
_, self.pan = ImGui.SliderFloat("Pan", self.pan, -1.0, 1.0)
2329
if ImGui.Button("Play") then
24-
lstg.PlaySound("啊!")
30+
lstg.PlaySound(SE_NAME, self.vol, self.pan)
2531
end
2632
if ImGui.Button("Pause") then
27-
lstg.PauseSound("啊!")
33+
lstg.PauseSound(SE_NAME)
2834
end
2935
if ImGui.Button("Resume") then
30-
lstg.ResumeSound("啊!")
36+
lstg.ResumeSound(SE_NAME)
3137
end
3238
if ImGui.Button("Stop") then
33-
lstg.StopSound("啊!")
39+
lstg.StopSound(SE_NAME)
3440
end
3541
end
3642
ImGui.End()

0 commit comments

Comments
 (0)