添加KeyEvent时没有声音

时间:2013-05-16 09:48:21

标签: audio lua corona keyevent

  

添加这段代码后,我已经失去了游戏的声音。即使音量控制按钮在播放时也不起作用。解决方案需要尽快解决。感谢。

Runtime:addEventListener( "key", onKeyEvent )

    function onKeyEvent( event )
        if (event.phase == "up" and event.keyName=="back") then
                goToTheMenu()
        end    
    end

1 个答案:

答案 0 :(得分:2)

将您的功能更改为:

function onKeyEvent( event )
    local keyname = event.keyName;
    if (event.phase == "up" and (event.keyName=="back" or event.keyName=="menu" or event.keyName == "home" )) then
        if keyname == "menu" or keyname == "back" or keyname == "home" then
            goToMenu()
            return true
        end
    end
    return false
end