Löve Frames - A GUI Library
Re: Löve Frames - A GUI Library
The buttons are getting rendered but the click event is not firing.
-
- Prole
- Posts: 6
- Joined: Sun Oct 11, 2009 1:53 am
Re: Löve Frames - A GUI Library
I have a game that does some deserializing of data using a serialize.lua library found on the forums.
With a os.clock() taken before and after running 1 deserialize() operation, the time is about .001 seconds.
Just by adding:
require("libs.loveframes")
and not even adding the update or draw events required by loveframes, the same deserialize() function process jumps to taking .7 seconds to complete.
Any idea why just including a require to loveframes makes my deserialize() operation increase by a couple orders of magnitude?
With a os.clock() taken before and after running 1 deserialize() operation, the time is about .001 seconds.
Just by adding:
require("libs.loveframes")
and not even adding the update or draw events required by loveframes, the same deserialize() function process jumps to taking .7 seconds to complete.
Any idea why just including a require to loveframes makes my deserialize() operation increase by a couple orders of magnitude?
- Nikolai Resokav
- Party member
- Posts: 140
- Joined: Wed Apr 28, 2010 12:51 am
- Location: United States
Re: Löve Frames - A GUI Library
Can you post a .love of your project?Rishavs wrote:The buttons are getting rendered but the click event is not firing.
Love Frames performs several tasks when you require it, and I haven't really taken the time to optimize any of them.LaggyNewbie wrote:I have a game that does some deserializing of data using a serialize.lua library found on the forums.
With a os.clock() taken before and after running 1 deserialize() operation, the time is about .001 seconds.
Just by adding:
require("libs.loveframes")
and not even adding the update or draw events required by loveframes, the same deserialize() function process jumps to taking .7 seconds to complete.
Any idea why just including a require to loveframes makes my deserialize() operation increase by a couple orders of magnitude?
-
- Prole
- Posts: 6
- Joined: Sun Oct 11, 2009 1:53 am
Re: Löve Frames - A GUI Library
I think I figured out the problem. There were global variable names being shared by both libraries (specifically the utf8.lua file) but not throwing any errors. I ended up changing the serialize library to Tserial.lua which doesn't appear to have any naming conflicts with the love frame library
-
- Prole
- Posts: 31
- Joined: Sun Dec 30, 2012 7:14 pm
Re: Löve Frames - A GUI Library
I have the same problem as Rishavs - the .OnClick callback for buttons does not work.
Here's my code (relevant parts on top):
It works flawlessly if I use .OnMouseEnter instead. It also works flawlessly in another older project, where I have _exactly_ the same syntax (and the libs were copied over from there).
I'll attach the .love
Here's my code (relevant parts on top):
Code: Select all
function love.load()
require("lib.Frames")
button_circles = loveframes.Create("button")
button_circles:SetWidth(200)
button_circles:SetText("Toggle Lines")
button_circles.x = 20
button_circles.y = 20
circles = false
button_circles.OnClick = function ()
circles = not circles
button_circles:SetText("test")
end
love.window.setMode(1280, 800)
math.randomseed(os.time())
math.random(); math.random(); math.random()
planet = {}
t = 0
--planets
planet.number = math.random(10)
sun = {}
sun.radius = math.random(30, 50)
sun.x = 1280/2
sun.y = 800/2
for i = 1, planet.number do
planet[i] = {}
planet[i].radius = math.random(5, sun.radius * 0.5)
if i == 1 then
planet[i].distance = math.random(sun.radius + planet[i].radius + 20, i*100)
else
planet[i].distance = math.random(planet[i - 1].distance + planet[i].radius + 20, i*75)
end
planet[i].T = math.pow(planet[i].distance, 3/2) * 10
planet[i].t = t + math.random(100000)
planet[i].x = sun.x + planet[i].distance*math.sin(2*math.pi/planet[i].T)
planet[i].y = sun.y + planet[i].distance*math.cos(2*math.pi/planet[i].T)
end
end
function love.update()
for i = 1, planet.number do
planet[i].t = planet[i].t + 1
planet[i].x = sun.x + planet[i].distance*math.sin(2*math.pi*planet[i].t/planet[i].T)
planet[i].y = sun.y + planet[i].distance*math.cos(2*math.pi*planet[i].t/planet[i].T)
end
loveframes.update()
end
function love.draw()
love.graphics.circle("fill", sun.x, sun.y, sun.radius)
for i = 1, planet.number do
love.graphics.circle("fill", planet[i].x, planet[i].y, planet[i].radius)
if circles then
love.graphics.circle("line", sun.x, sun.y, planet[i].distance)
end
end
loveframes.draw()
end
I'll attach the .love
- Attachments
-
- solsysgen.love
- (140.51 KiB) Downloaded 194 times
- Nikolai Resokav
- Party member
- Posts: 140
- Joined: Wed Apr 28, 2010 12:51 am
- Location: United States
Re: Löve Frames - A GUI Library
You need to add the mousepressed and mousereleased callbacks:Ford_Prefect wrote:I have the same problem as Rishavs - the .OnClick callback for buttons does not work.
Here's my code (relevant parts on top):
It works flawlessly if I use .OnMouseEnter instead. It also works flawlessly in another older project, where I have _exactly_ the same syntax (and the libs were copied over from there).Code: Select all
function love.load() require("lib.Frames") button_circles = loveframes.Create("button") button_circles:SetWidth(200) button_circles:SetText("Toggle Lines") button_circles.x = 20 button_circles.y = 20 circles = false button_circles.OnClick = function () circles = not circles button_circles:SetText("test") end love.window.setMode(1280, 800) math.randomseed(os.time()) math.random(); math.random(); math.random() planet = {} t = 0 --planets planet.number = math.random(10) sun = {} sun.radius = math.random(30, 50) sun.x = 1280/2 sun.y = 800/2 for i = 1, planet.number do planet[i] = {} planet[i].radius = math.random(5, sun.radius * 0.5) if i == 1 then planet[i].distance = math.random(sun.radius + planet[i].radius + 20, i*100) else planet[i].distance = math.random(planet[i - 1].distance + planet[i].radius + 20, i*75) end planet[i].T = math.pow(planet[i].distance, 3/2) * 10 planet[i].t = t + math.random(100000) planet[i].x = sun.x + planet[i].distance*math.sin(2*math.pi/planet[i].T) planet[i].y = sun.y + planet[i].distance*math.cos(2*math.pi/planet[i].T) end end function love.update() for i = 1, planet.number do planet[i].t = planet[i].t + 1 planet[i].x = sun.x + planet[i].distance*math.sin(2*math.pi*planet[i].t/planet[i].T) planet[i].y = sun.y + planet[i].distance*math.cos(2*math.pi*planet[i].t/planet[i].T) end loveframes.update() end function love.draw() love.graphics.circle("fill", sun.x, sun.y, sun.radius) for i = 1, planet.number do love.graphics.circle("fill", planet[i].x, planet[i].y, planet[i].radius) if circles then love.graphics.circle("line", sun.x, sun.y, planet[i].distance) end end loveframes.draw() end
I'll attach the .love
Code: Select all
function love.mousepressed(x, y, button)
loveframes.mousepressed(x, y, button)
end
function love.mousereleased(x, y, button)
loveframes.mousereleased(x, y, button)
end
-
- Prole
- Posts: 31
- Joined: Sun Dec 30, 2012 7:14 pm
Re: Löve Frames - A GUI Library
Many thanks. Much appreciated. Me fail.Nikolai Resokav wrote:You need to add the mousepressed and mousereleased callbacks:Ford_Prefect wrote:I have the same problem as Rishavs - the .OnClick callback for buttons does not work.
Here's my code (relevant parts on top):
It works flawlessly if I use .OnMouseEnter instead. It also works flawlessly in another older project, where I have _exactly_ the same syntax (and the libs were copied over from there).Code: Select all
function love.load() require("lib.Frames") button_circles = loveframes.Create("button") button_circles:SetWidth(200) button_circles:SetText("Toggle Lines") button_circles.x = 20 button_circles.y = 20 circles = false button_circles.OnClick = function () circles = not circles button_circles:SetText("test") end love.window.setMode(1280, 800) math.randomseed(os.time()) math.random(); math.random(); math.random() planet = {} t = 0 --planets planet.number = math.random(10) sun = {} sun.radius = math.random(30, 50) sun.x = 1280/2 sun.y = 800/2 for i = 1, planet.number do planet[i] = {} planet[i].radius = math.random(5, sun.radius * 0.5) if i == 1 then planet[i].distance = math.random(sun.radius + planet[i].radius + 20, i*100) else planet[i].distance = math.random(planet[i - 1].distance + planet[i].radius + 20, i*75) end planet[i].T = math.pow(planet[i].distance, 3/2) * 10 planet[i].t = t + math.random(100000) planet[i].x = sun.x + planet[i].distance*math.sin(2*math.pi/planet[i].T) planet[i].y = sun.y + planet[i].distance*math.cos(2*math.pi/planet[i].T) end end function love.update() for i = 1, planet.number do planet[i].t = planet[i].t + 1 planet[i].x = sun.x + planet[i].distance*math.sin(2*math.pi*planet[i].t/planet[i].T) planet[i].y = sun.y + planet[i].distance*math.cos(2*math.pi*planet[i].t/planet[i].T) end loveframes.update() end function love.draw() love.graphics.circle("fill", sun.x, sun.y, sun.radius) for i = 1, planet.number do love.graphics.circle("fill", planet[i].x, planet[i].y, planet[i].radius) if circles then love.graphics.circle("line", sun.x, sun.y, planet[i].distance) end end loveframes.draw() end
I'll attach the .love
Code: Select all
function love.mousepressed(x, y, button) loveframes.mousepressed(x, y, button) end function love.mousereleased(x, y, button) loveframes.mousereleased(x, y, button) end
edit: While I'm at it, I have another question.
If I create slider and set it's default value, how do I get the slider to actually be at the corresponding point for that value? It's always stuck to the very left (horizontal slider) for me.
Re: Löve Frames - A GUI Library
is it possible to rename love frames when requiring it?
- Nikolai Resokav
- Party member
- Posts: 140
- Joined: Wed Apr 28, 2010 12:51 am
- Location: United States
Re: Löve Frames - A GUI Library
Love Frames is returned when you require it, so something like this should work:Doctory wrote:is it possible to rename love frames when requiring it?
Code: Select all
gui = require("path.to.loveframes")
Re: Löve Frames - A GUI Library
I'm trying to retrieve the name of an object using GetHoverObject, but having iterated through the table it returns, the names I gave the objects do not exist. Closest I get is "instance of class loveframes_object_imagebutton" or similar. I'm trying to retrieve the name to match it against a table value (the objects name). See "obj[x]"
Code: Select all
if loveframes.util.GetHoverObject() then
obj = loveframes.util.GetHoverObject()
for k, v in ipairs(tbl) do
if obj[x] == v then
...
end
end
end
Who is online
Users browsing this forum: No registered users and 4 guests