-
Notifications
You must be signed in to change notification settings - Fork 2
Sonido
ACharLuk edited this page Jan 24, 2018
·
1 revision
-
Hay una clase más que aun no hemos usado, la clase
sound. Te da la habilidad de cargar sonidos y reproducirlos/pausarlos/detenerlos. -
El uso es muy sencillo, aquí tienes un ejemplo:
local mySound
...
function setup()
...
mySound = sound:new{ path = "direccion/del/sonido/sonidoEjemplo.wav" }
end
function render()
...
end
function input()
if keys['Z'] then
mySound:play()
end
if keys['X'] then
mySound:pause()
end
if keys['C'] then
mySound:stop()
end
end-
Este código reproduce el sonido "direccion/del/sonido/sonidoEjemplo.wav" cuando pulsas 'Z', pausa cuando pulsas 'X' y lo detiene cuando pulsas la tecla 'C'.
-
Tambien puedes empezar a reproducir un sonido en la función
setup, esto es útil si quieres tener música reproduciendose mientras el juego esta abierto.
-
Fabuloso! Ahora ya sabes como usar la clase
sound!
-
Tutorials