Created
October 20, 2012 15:53
-
-
Save shawngrimes/3923696 to your computer and use it in GitHub Desktop.
Create a Button with Corona SDK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--This adds the widget library to our project | |
local widget = require "widget" | |
--This is what is run when we press our button | |
local myButtonEvent = function (event ) | |
if event.phase == "release" then | |
print( "You pressed and released the "..event.target.id.." button!" ) | |
end | |
end | |
--This will create a button using images | |
local myButton=widget.newButton{ | |
--The id can be used to tell you what button was pressed in your button event | |
id = "mainMenuButton", | |
--this is the default button image | |
default="button_main_up.png", | |
--this is the image to use when the button is pressed | |
over="button_main_down.png", | |
--this tells it what function to call when you press the button | |
onEvent = myButtonEvent | |
} | |
--This will create a button using text | |
local myButton=widget.newButton{ | |
--The id can be used to tell you what button was pressed in your button event | |
id = "myTextButton", | |
--This is the text label to put on the button | |
label = "My Button", | |
--This is the start x coordinate of the Top Left Corner | |
left=150, | |
--This is the start y coordinate of the Top Left Corner | |
top=150, | |
--Emboss can be true or false, tells it to make the label look embossed/inset | |
emboss=true, | |
--The border around the outside of the button | |
strokeWidth=4, | |
--How round to make the corners | |
cornerRadius=8, | |
--this tells it what function to call when you press the button | |
onEvent = myButtonEvent | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment