I am very new to Löve, so this question is probably silly - but I could not find an answer in the discussion above.
I would like to be able to customize differently each button (for instance set the button 1 background to image1, the button 2 background to image2, etc).
So I can't really change the style-default file.
function love.load()
image1 = love.graphics.newImage("Images/Button1.png")
end
function love.update(dt)
if gui.Button ({text = "Blabla",image1, pos = {300, 200}, size = {200, 50}})
then -- do something
end
end
As far as I can tell you need to write your own button class. You can base it on the default button class.
You also need to add your new class to init.lua and style-default.lua.
to the top of your main/game lua (in this case, move the folder with all the library files into where main.lua is and name it 'Quickie'.). From then on, you can just call the function to add a button or whatever form you want in update. Make sure to draw it. Here's some super simple example code
gui = require "Quickie"
function love.load()
end
function love.update(dt)
gui.Button{text = "foo"} --this creates a button that does nothing with the text "foo"
if gui.Button{text = "bar", pos = {50, 50}} then --this creates a button that has the text "bar", a position of 50,50, and prints "foobar" when you click on it. The functions you call return true if they are activated.
print("foobar")
end
end
function love.draw()
gui.core.draw()
end
You can generally get how to use most of them from looking at the example code on github.
I wish I could release my game (still waiting for a single asset to be replaced). There you could see how it is used in a real game and also how I solved some of the problems I encountered along the way (keyboard focus with multiple menu screens, sound on button mouseover).
From my experience I'd say only use quickie if what you need is really simple, like a single menu screen for example. Mind you, I don't have any experience with the ohter Löve GUIs, but I'll try one of those for my next project.
to the top of your main/game lua (in this case, move the folder with all the library files into where main.lua is and name it 'Quickie'.). From then on, you can just call the function to add a button or whatever form you want in update. Make sure to draw it. Here's some super simple example code
gui = require "Quickie"
function love.load()
end
function love.update(dt)
gui.Button{text = "foo"} --this creates a button that does nothing with the text "foo"
if gui.Button{text = "bar", pos = {50, 50}} then --this creates a button that has the text "bar", a position of 50,50, and prints "foobar" when you click on it. The functions you call return true if they are activated.
print("foobar")
end
end
function love.draw()
gui.core.draw()
end
You can generally get how to use most of them from looking at the example code on github.
Thanks!
Also, I don't have to keep the .gitignore file, correct?
You don't need to keep a .gitignore file or .git directory if all you want to do is use quickie. Both are just related to version control and are not necessary for quickie to work.
Hi there! I hope I haven't missed an answer to this question, but I'd like to override the mouse position getter for Quickie. I don't really know much about metatables etc, but given that it's mentioned in this commit, how do I do this?
Good day! How can I change the color of a separate block of text (label for example)?
My library for easy saving Slib! Try this! Now you can encrypt your save!
- Drop of light LD#30
- OUTRANGE LD#31 (Sorry for my english. I learn it myself, and I don't have enough experience)