How do I Make Buttons that play sound when touched? I’m totally new/lost. [import]uid: 16789 topic_id: 5144 reply_id: 305144[/import]
This is how i currently do it. You will need to include the ui.lua file
local ui = require ( "ui" )
-- Note this assumes the audio files is in a folder named "audio"
local ballsAppearSoundID = audio.loadSound( "audio/bbSwoosh.caf" )
local playBallsAppearSound = function()
audio.play( ballsAppearSoundID )
end
-- This assumes the button images are contained in a folder named "images"
local playSoundButton = ui.newButton{
default = "images/playSoundButtonDefault.png",
over = "images/playSoundButtonHighlight.png"
}
playSoundButton.x = 16; playSoundButton.y = 16
local function clickPlaySoundButton ( event )
if event.phase == "ended" then
playBallsAppearSound()
end
end
playSoundButton:addEventListener("touch",clickPlaySoundButton)
Hope that helps. There may be a better / easier way to do this [import]uid: 7863 topic_id: 5144 reply_id: 17023[/import]
I have a template available here; http://buypremadeapps.com/Buy_Premade_Apps/Templates.html
Available with any donation amount.
Being a soundboard it’s got a number of buttons that play sounds, laid out very neatly 
You may or may not want it but I figure it doesn’t hurt to put it out there
[import]uid: 10144 topic_id: 5144 reply_id: 17046[/import]