【发布时间】:2017-12-26 23:40:38
【问题描述】:
我是 Corona 游戏开发的新手,如果这有助于我在游戏中添加 播放/停止 按钮,这是我用来播放背景音乐的功能:
local backgroundMusicChannel
local backgroundMusicSounds = {}
if (backgroundMusic == true) then
for i=1, backgroundMusicNumber do
backgroundMusicSounds["bg" .. i] = audio.loadStream("sounds/bg" .. i ..".mp3")
end
end
function playBackgroundMusic()
if (backgroundMusic == true) then
backgroundMusicChannel = audio.play( backgroundMusicSounds["bg" .. math.random(1,backgroundMusicNumber)], { channel=5, loops=-1 } )
end
end
function stopBackgroundMusic()
if (backgroundMusic == true) then
audio.stop( backgroundMusicChannel )
end
end
【问题讨论】:
-
显示你到目前为止所做的事情。
-
其实我根本没有找到解决办法
-
所以也许最好从Chapter 1 — Creating an App 开始,然后再深入:) 祝你好运。
标签: coronasdk