How to add "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
User avatar
dataFRAME
Prole
Posts: 14
Joined: Sat Feb 07, 2009 9:12 pm
Location: Germany

How to add "Buttons"?

Post by dataFRAME »

Hello, its me again!
Sorry for the big amount of questions but i am enjoying those answers in here :P

sSo next step:
How to realize Buttons?
I mean those clicky Buttons like in Java, how to do it in love or how to do it in 2d ways?

Thank you!
Intrested in making music? Theres a Virtual Drum - Software for LÖVE
http://love2d.org/forum/viewtopic.php?f ... bumm#p4193
User avatar
mike
Administrator
Posts: 364
Joined: Mon Feb 04, 2008 5:24 pm

Re: How to add "Buttons"?

Post by mike »

Buttons? What? Maybe you're looking for one of the GUI libraries that you can use to make buttons: bottom-right area of main wiki page
Now posting IN STEREO (where available)
User avatar
dataFRAME
Prole
Posts: 14
Joined: Sat Feb 07, 2009 9:12 pm
Location: Germany

new stuff

Post by dataFRAME »

So Mates,

holidays...sun is shining and i am sitting in front of my PC and try to add buttons bymyself,
i am not the best programmer but ill try it to figure it out so.

I've got a way to display "buttons" but: (Jeah the big BUT..)

I dont know how the hell i can identify my buttons with names..ill post my way to do it.

Code: Select all

--[[Functions]]--
--[[ A function to create a Button with a couple of Attributes
Attributes:
      name = name of the button *test*
      type = is it filled?
   x_start = start-position X-Axis
   y_start = start-position Y-Axis
     witdh = witdh off the button
    height = height off the button
   caption = text in the middle of the button
text_color = color of the text
     color = color of the button
]]--

function create_button(type,x_start,y_start,witdh,height,caption,text_color,color,nr)
    love.graphics.setColor( color )
	love.graphics.rectangle( type, x_start, y_start, witdh, height)
	love.graphics.setColor( text_color )
	love.graphics.draw(caption,x_start+witdh/2-font_size/2,y_start+height/2)
end
So thats my way! A function with alot of parameters.
It creates a rectangle with a text in it, if it created once, i couldnt "talk to it"
thats all thank you
Intrested in making music? Theres a Virtual Drum - Software for LÖVE
http://love2d.org/forum/viewtopic.php?f ... bumm#p4193
User avatar
qubodup
Inner party member
Posts: 775
Joined: Sat Jun 21, 2008 9:21 pm
Location: Berlin, Germany
Contact:

Re: How to add "Buttons"?

Post by qubodup »

Tables

Please let us know whether you're ok with reading this documentation (and whether you understood how to use them if you did) or if you need more guidance.
lg.newImage("cat.png") -- made possible by lg = love.graphics
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)
User avatar
Gerrit
Prole
Posts: 46
Joined: Wed Mar 25, 2009 7:40 pm

Re: How to add "Buttons"?

Post by Gerrit »

Hey.

After reading the table stuff take a look at my sample. Arrays/Tables are necessary for mostly everything you'll ever do (in programming) so get used to them :) The supplied demo is really basic but it's mostly what you tried to do. Except the color Stuff, who needs colors anyway ;) Anyways, I hope this will help you a bit. Try to modify the script a little. Maybe make a button & function to make new buttons on the fly. Should be a no-brainer.
Attachments
loveButtons.love
Simple demo for clickable buttons in Löve without frameworks
(1.79 KiB) Downloaded 389 times
User avatar
dataFRAME
Prole
Posts: 14
Joined: Sat Feb 07, 2009 9:12 pm
Location: Germany

Re: How to add "Buttons"?

Post by dataFRAME »

Thank you for the help!
@qubodup

Please let us know whether you're ok with reading this documentation (and whether you understood how to use them if you did) or if you need more guidance.
It helps me a lot, thank you for it!

@Gerrit

Thank you for this example, ill work it through the day, thanks!

...(insane help! Thank you!)
Intrested in making music? Theres a Virtual Drum - Software for LÖVE
http://love2d.org/forum/viewtopic.php?f ... bumm#p4193
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests