Buttons
i know how to make buttons, but it’s annoying. Is there any built-in button functions or anything of the sort
i know how to make buttons, but it’s annoying. Is there any built-in button functions or anything of the sort
if you mean buttons for touch screens or to click on, then there are no built in functions to my knowledge. there may be libraries out there you can use, but you'll probably just have to make your own
You can use my function, and if needed, you can replace the rectangle drawing with sprites.
button = function(x,y,w,h,textSize,text)
isHover = abs(mouse.x-x)<w/2 and abs(mouse.y-y)<h/2
isPressed = mouse.pressed or touch.press
if (isHover and isPressed) then
screen.fillRoundRect(x,y,w,h,2,"#48CFAD")
screen.drawText(text,x,y,textSize,"#434A54")
return true
else
screen.fillRoundRect(x,y,w,h,2,"#37BC9B")
screen.drawText(text,x,y,textSize,"#434A54")
return false
end
end
you should publish this as a library