Here is a great class for creating buttons in Gideros Mobile SDK https://github.com/gideros/Button. It 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.
Here is an example usage of button class in Gideros Mobile:
local button_default = Bitmap.new(Texture.new("images/start.png")) 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 )