Help, need buttons.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
SniX
Prole
Posts: 24
Joined: Mon Aug 26, 2013 10:18 am

Help, need buttons.

Post by SniX »

All ways i found to create buttons are really messy and ineffective, anyone has any suggestions for main menu buttons?
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: Help, need buttons.

Post by Plu »

What ways have you found? There's a few libraries on the wiki that're quite good, like Quickie and LoveFrames.

http://www.love2d.org/wiki/Category:Libraries
SniX
Prole
Posts: 24
Joined: Mon Aug 26, 2013 10:18 am

Re: Help, need buttons.

Post by SniX »

Emm, all i could think of was checking coordinates every time left mouse button has been pressed down, but my menu consists of 6 diffrent choices, that would take a lot of lines of code, so i didnt bother.
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: Help, need buttons.

Post by Plu »

Checking the mouse coordinates and matching it against any active buttons is pretty much the way to go. But the libraries I mentioned will do it for you.
User avatar
Xrott
Prole
Posts: 16
Joined: Thu Aug 15, 2013 1:28 pm
Location: Augsburg

Re: Help, need buttons.

Post by Xrott »

How about simply putting every button in a table, so you could just iterate over them, like this:

Code: Select all

for i = 1, #buttons do
	if mouseX > buttons[i].x 
	and mouseX < buttons[i].width + buttons[i].x 
	and mouseY > buttons[i].y 
	and mouseY < buttons[i].height + buttons[i].y then
		--your code
	end
end
User avatar
Eamonn
Party member
Posts: 550
Joined: Sat May 04, 2013 1:29 pm
Location: Ireland

Re: Help, need buttons.

Post by Eamonn »

Well, check out Sock Munkee dev's video on it, if all you need are simple text buttons, but if you want to make GUI's and some better looking buttons, I'd say look into LöveFrames. It's very easy to use, there is extensive documentation on it and(PLUG!) I make my own tutorial series on LÖVE, and all I have to do is upload those episodes tonight and you could follow those to learn how to make buttons. I would suggest at least checking out some of those libraries: They could save you a lot of headaches.
"In those quiet moments, you come into my mind" - Liam Reilly
SniX
Prole
Posts: 24
Joined: Mon Aug 26, 2013 10:18 am

Re: Help, need buttons.

Post by SniX »

I have a little problem using other peoples codes, i can't really understand what is going on if i haven't made it myself :P
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Help, need buttons.

Post by raidho36 »

That's a common thing actually. It gets especially bad if people don't format their code properly - don't use tabs *coughjjmafiaecough* or whitespaces *coughmonkeymancough*. And of course if they don't comment obscure algorithms *couggthembothandmanyotherscough* it gets REALLY hard to read others' code.
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Help, need buttons.

Post by davisdude »

I think he means more along the lines of something like this:
Since they didn't make it, they don't know how it works. That's at least true for me. :P
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
iPoisonxL
Party member
Posts: 227
Joined: Wed Feb 06, 2013 3:53 am
Location: Australia
Contact:

Re: Help, need buttons.

Post by iPoisonxL »

I always like a thorough explanation of what the code does, so I can be able to write my own version of it.

Code: Select all

      L
    L Ö
    Ö V
L Ö V E
Ö B E
V E
E Y
Website
Post Reply

Who is online

Users browsing this forum: ncrecc and 2 guests