I decided about a week ago to make a gui class for a toolbar sort of thing, so far I have: A Button, Dial, Slider, Toggle, Drop down menu. I want to continue creating this class and release it when I’ve finished for everyone to use. The aim for this is that people can easily add a UI to their game. Here is an example of how these functions work:
--Button command: Button(Position,Size,Text,Colour,BorderWidth,CallBack)
var1 = "Press Me" --readImage("Cargo Bot:Clear Button")
btn = Button(vec2(WIDTH/2,HEIGHT/2),vec2(100,60),var1,
color(154, 227, 8, 255),5,function() print("test") end)
var = 100
--Slider command: Slider(Position,Size,StartValue,EndValue,Value)
--Note: Size variable must always be vec2. If the 'y' value of the Size variable is less than
------- 20 then the Slider will remain as a linear (single valued) Slider, but if the 'y'
------- value is greater than 20 then this means the Slider becomes a scalar valued Slider,
------- allowing for 2D movement of the axis, this type of slider needs the StartVal,EndVal
------- and Value variables to be Scalar variables (vec2(x,y)). If the Slider is a linear
------- Slider then the StartValue,EndValue and Value variables must remain linear otherwise
------- this will cause errors.
sldr = Slider(vec2(WIDTH/2,300),vec2(150,15),50,200,var)
var2 = 0
--Toggle command: Toggle(Position,Size,Value) , Toggle Value: Toggle:getValue()
tog = Toggle(vec2(WIDTH/2,HEIGHT/2+100),vec2(75,30),var2)
--Dial command: Dial(Position,Size,StartVal,EndVal,Value) , Dial Value: Dial:getValue()
dial = Dial(vec2(WIDTH/2,HEIGHT/2+200),65,0,20,10)
dial:setFloat(0)
--Drop Down Menu command: DMenu(Position,Size) , DMenu item: DMenu:addItem(Name,Callback)
dropd = DMenu(vec2(WIDTH/2+200,HEIGHT/2),vec2(150,30))
dropd:addItem("try me",function() print("test") end)
dropd:addItem("try me2",function() print("test2") end)
Here’s what it looks like, hopefully you know which one is which!
http://i269.photobucket.com/albums/jj69/qwerty-keyboard-bucket/image.jpg