Button

About Button

Type: Gideros class
License: MIT License
Supported platforms:

       

Categories:
  • User Interface

Button class implements two states of button, making your buttons more responsive :

  • standard state
  • pushed state

Another great feature is that it implements click event, which executes only for this button. By default mouse interaction events are called for all siblings, no matter if you clicked on specific object or not. That's why usually you need to call hitTestPoint to check whether event was called for this object. Click event in button class already handles that for you, so you don't need to worry about it.

Download Button

Developed by: Gideros

Sharing is caring:

Code example:

local button_pushed = Bitmap.new(Texture.new("images/start_down.png"))
 
local startButton = Button.new(button_default, button_pushed)
 
local x = ((application:getDeviceWidth()-startButton:getWidth())/2)
local y = ((application:getDeviceHeight()-startButton:getHeight())-20)
 
startButton:setPosition(x, y)
stage:addChild(startButton)
 
startButton:addEventListener("click", 
    function()  
        //do what you want on click
    end
)