如何播放一个按钮点击的声音,只有一次在电晕sdk?
当用户点击按钮时,我只想播放一次声音,我怎么能做到 以下是我到目前为止所做的工作,但如何添加声音:如何播放一个按钮点击的声音,只有一次在电晕sdk?,sdk,lua,coronasdk,Sdk,Lua,Coronasdk,当用户点击按钮时,我只想播放一次声音,我怎么能做到 以下是我到目前为止所做的工作,但如何添加声音: local widget = require( "widget" ) --button performed only once local minusButtonPressed = false local function handleButtonEvent( event ) if ( ( "ended" == event.phase ) and (minusButtonPressed
local widget = require( "widget" )
--button performed only once
local minusButtonPressed = false
local function handleButtonEvent( event )
if ( ( "ended" == event.phase ) and (minusButtonPressed == false) and (afterCorrect == false)) then
minusScore()
print( "Button was pressed and released" )
--disable the button
minusButtonPressed = true
end
end
local button1 = widget.newButton
{
width = 350,
height = 360,
left= 30,
top= 220,
defaultFile = "speakers.png",
overFile = "wrong.png",
--label = "button",
onEvent = handleButtonEvent
}
我不知道这是否是您的程序所需要的,但请尝试包含音频库 和使用
local laserSound = audio.loadSound( "laserBlast.wav" ) //init the sound
local laserChannel = audio.play( laserSound ) //play the sound once complete