How do you make buttons?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
How do you make buttons?
I wanna make a game with the start button but how do you make a text button?
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: How do you make buttons?
I'd recommend using Quickie if you're new to Lua.
Kurosuke needs beta testers
Re: How do you make buttons?
still dont get it.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: How do you make buttons?
What don't you get? The more specific you are the more we can help you.
Kurosuke needs beta testers
Re: How do you make buttons?
There isn't no imbued UI objects in LOVE. So you will need use a library like Quickie as tentus suggested. However if you need simple things and you want to learn doing yourself stuff maybe you can make a very simple and basic library.ok3y11 wrote:I wanna make a game with the start button but how do you make a text button?
Steps to do it:
1 - Draw a rectangle or load a image to use as button.
2 - Get rectangle/image and text size and determine where to print text over the rectangle/image
3 - in love.update call a routine that detects if it happen a click when mouse is over button area. Call the wanted routine if clicked
4 - in love.draw call a routine that draws the button/text.
Basically it's that. If you search in forum more people asked how to do that like this thread viewtopic.php?f=4&t=3386
Re: How do you make buttons?
Code: Select all
function love.mousepressed(x, y, click)
if click == "l"(l as in left click) then
if x >= (x pos of the button img) and x <= (x pos + width of img) and y >= (y pos of the button img) and y <= (y pos + width of img) then
--function
end
end
end
I write rules for my computer... I'm not the ruler of the world(yet)... Also, I livestream stuff http://NateAGeek.com/Live
Re: How do you make buttons?
Quickie:
That's it.
Code: Select all
GUI = require "Quickie"
function love.update(dt)
if GUI.Button("Start", 200, 200, 100, 50) then
-- start game function
end
end
function love.draw()
GUI.core.draw()
end
Who is online
Users browsing this forum: Amazon [Bot], Bing [Bot], Google [Bot] and 7 guests