main.lua 546 B

12345678910111213141516171819
  1. function lovr.load()
  2. source = lovr.audio.newSource('sine.wav')
  3. source:setLooping(true)
  4. source:play()
  5. muted = false
  6. end
  7. function lovr.update()
  8. if lovr.headset.wasPressed('left', 'trigger') or lovr.headset.wasPressed('right', 'trigger') then
  9. muted = not muted
  10. lovr.audio.setVolume(muted and 0 or 1)
  11. end
  12. end
  13. function lovr.draw(pass)
  14. local font = lovr.graphics.getDefaultFont()
  15. pass:text(muted and 'Muted' or 'Unmuted', 0, 1.7, -1, .1)
  16. pass:text('Press trigger to toggle mute', 0, 1.7 - font:getHeight() * .2, -1, .1)
  17. end