local widget = require( “widget” )
local background = display.newImage(“carbonfiber.jpg”, true) – flag overrides large image downscaling
background.x = display.contentWidth / 2
background.y = display.contentHeight / 2
local GodzillaMarc785758480mp3 = audio.loadSound(“GODZILLA”)
local GroanSoundBiblecom1306380507mp3 = audio.loadSound(“groan”)
local PieceOfCrapKevanGC288403955mp3 = audio.loadSound(“FART1”)
local roundedRect = display.newRoundedRect( 10, 50, 300, 40, 8 )
roundedRect.anchorX, roundedRect.anchorY = 0.0, 0.0 – simulate TopLeft alignment
roundedRect:setFillColor( 0/255, 0/255, 0/255, 170/255 )
local t = display.newText( “Waiting for button event…”, 0, 0, native.systemFont, 18 )
t.x, t.y = display.contentCenterX, 70
– Create 5 buttons, using different optional attributes
local button1Press = function( event )
t.text = “O MY GOD!!!”
end
local button1Release = function( event )
t.text = “GODZILLA”
end
local buttonHandler = function( event )
t.text = "id = " … event.target.id … ", phase = " … event.phase
end
function myButton1 = function( event )
audio.play(Godzilla-Marc)
end
local button1 = widget.newButton
{
defaultFile = “buttonRed.png”,
overFile = “buttonRedOver.png”,
label = “Godzilla”,
emboss = true,
onPress = button1Press,
onRelease = button1Release,
}
local button2Press = function( event )
t.text = “Um…”
end
local button2Release = function( event )
t.text = “…”
end
local buttonHandler = function( event )
t.text = "id = " … event.target.id … ", phase = " … event.phase
end
function myButton2:tap( event )
audio.play(Groan-SoundBible.com)
end
local button2 = widget.newButton
{
id = “button2”,
defaultFile = “buttonYellow.png”,
overFile = “buttonYellowOver.png”,
label = “groan”,
labelColor =
{
default = { 51, 51, 51, 255 },
},
font = native.systemFont,
fontSize = 22,
emboss = true,
onPress = button2Press,
onRelease = button2Release,
}
local button3Press = function( event )
t.text = “O MY GOD!!!”
end
local button3Release = function( event )
t.text = “”
end
local buttonHandler = function( event )
t.text = "id = " … event.target.id … ", phase = " … event.phase
end
function myButton3:tap( event )
audio.play(Piece_Of_Crap-KevanGC)
end
local button3 = widget.newButton
{
id = “button3”,
defaultFile = “buttonGray.png”,
overFile = “buttonBlue.png”,
label = “FART 1”,
font = native.systemFont,
fontSize = 28,
emboss = true,
onPress = button3Press
}
button1.x = 160; button1.y = 160
button2.x = 160; button2.y = 240
button3.x = 160; button3.y = 320