Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
My simple button pad class - Gideros Forum

My simple button pad class

rrraptorrrraptor Member
edited October 24 in Code snippets
So, I decided to create a simple math game for myself to play it on my phone, and when I reached the state where I need to add some form of input I decided to investigate the layouts :smile:
And i came up with this:


It wasn't too hard to create this, but I had a little bit of a pain with text fields :smiley: Its not perfect, but a start point.

Uploaded code to github.

https://github.com/MultiPain/Gideros_ButtonPad

A little example (from GitHub)
local pad = Pad.new{
	w = 300, h = 300, -- pixel pad size
	rows = 3, -- number of rows
	columns = 3, -- number of columns
	color = 0x272727, -- background color
	margin = 4, -- margin from pad's cornders
	innerMargin = 2 -- margin between buttons inside
}
 
pad:addButton{ 
	x = 0, -- 0 based layout x index
	y = 0, -- 0 based layout y index
	scaleX = 4, -- textfiled scale x
	scaleY = 4, -- textfiled scale x
	bgColor = 0x323232, -- button bg color
	txtColor = 0xffffff, -- button text color
	name = "Erase", -- button name
	text = "<"  -- text to display
}
 
function padClick(e)
	local name = e.name -- button name
	local btext = e.text -- button text
	print(name, btext)
end
 
 
-- handle click on button
pad:addEventListener("click", padClick)
stage:addChild(pad)</pre>
333.png
359 x 242 - 16K
333.png 15.9K
+1 -1 (+4 / -0 ) Share on Facebook
Sign In or Register to comment.