Page 5 of 7

Re: Goo: Gui and Animation library.

Posted: Sat Nov 06, 2010 7:53 pm
by adrix89
I know why: the folder is named "Dark", while the code refers to "dark". Capitalization matters! Renaming it makes it work in .loves and on Linux/Mac.
Ok it works
Where?
I mean my post,edited something

Re: Goo: Gui and Animation library.

Posted: Sat Nov 13, 2010 10:42 pm
by Lap
ATTENTION TO EVERYONE USING GOO! SERIOUS BUG THAT NEEDS TO BE FIXED!

Code: Select all

function goo.object:destroy()
	if self.parent then
		for k,v in pairs(self.parent.children) do
			if v == self then table.remove(self.parent.children,k) end
		end
	end
	for i,child in ipairs(self.children) do
		child:destroy()
	end
	self = nil
	return
end
Needs to become:

Code: Select all

function goo.object:destroy()
	if self.parent then
		for k,v in pairs(self.parent.children) do
			if v == self then 
			table.remove(self.parent.children,k)
				for i = self.z, #self.parent.children do
				self.parent.children[i].z = i
				end
			end
		end
	end
	for i,child in ipairs(self.children) do
		child:destroy()
	end
	self = nil
	return
end
This bug has been silently plaguing me for months. All sorts of goo objects and other elements would seemingly disappear at random. I thought it was related to the many changes I've made to goo, but I just confirmed it's a long standing bug.

Without this you'll "lose" goo elements. You can check them and their tables will still exist, but they won't be drawn. The reason for all of this is that in the standard release of Goo, when objects are destroyed the other objects on higher layers will not update correctly. This causes layers to later get overwritten in the main BASEOBJECT table, orphaning them forever. Now feed me your karma :ultraglee:

Re: Goo: Gui and Animation library.

Posted: Tue Nov 23, 2010 5:28 pm
by whitebear
How would I go about doing this in essence:

Code: Select all

function PerkList[i].button:onClick ()
	if PerkList[i].hasit == 0 then
	if Points => PerkList[i].cost then
	Points = Points - PerkList[i].cost
		PerkList[i].hasit = 1
	end
	elseif PerkList[i].hasit == 1 then
	Points = Points + PerkList[i].cost
		PerkList[i].hasit = 0
	end
	panel:setTitle( "Traits ( You have ".. Points.." points to spend)" )
end
The function doesn't like having in it's call. Is there some way to do this without causing an error?

Re: Goo: Gui and Animation library.

Posted: Tue Nov 23, 2010 7:10 pm
by Robin
whitebear wrote:The function doesn't like having in it's call. Is there some way to do this without causing an error?

That's because it isn't a call, it's a definition.

Fortunately, Lua being Lua, you can do this:

Code: Select all

PerkList[i].button.onClick = function (self)
	if PerkList[i].hasit == 0 then
	if Points => PerkList[i].cost then
	Points = Points - PerkList[i].cost
		PerkList[i].hasit = 1
	end
	elseif PerkList[i].hasit == 1 then
	Points = Points + PerkList[i].cost
		PerkList[i].hasit = 0
	end
	panel:setTitle( "Traits ( You have ".. Points.." points to spend)" )
end

Re: Goo: Gui and Animation library.

Posted: Sun Nov 28, 2010 4:48 am
by whitebear
This is one of the best gui's out there but has anyone gotten the goo.text working? because either the code has bug or it's done differently from goo.textinput
There is no simple text object in example so it's possible it was missed in beta testing.

Re: Goo: Gui and Animation library.

Posted: Sun Nov 28, 2010 7:24 am
by adrix89
whitebear wrote:This is one of the best gui's out there but has anyone gotten the goo.text working? because either the code has bug or it's done differently from goo.textinput
There is no simple text object in example so it's possible it was missed in beta testing.
My version works,but its for 0.7
It also doesn't have the fix Lap was talking about

Re: Goo: Gui and Animation library.

Posted: Sun Nov 28, 2010 9:16 am
by whitebear
I fixed the text.lua file
Should work with this. Not sure how well it works when getting off the borders but at least doesn't give error.
The original file:

Code: Select all

-- STATIC TEXT
goo.text = class('goo static text', goo.object)
function goo.text:initialize( parent )
	super.initialize(self,parent)
	self.text = "no text"
end
function goo.text:draw(x,y)
	love.graphics.setColor( unpack(self.color) )
	love.graphics.print( self.text, x, y )
end
function goo.text:setText( text )
	self.text = text or ""
end
function goo.text:getText()
	return self.text
end

return goo.text
New file:

Code: Select all

-- STATIC TEXT
goo.text = class('goo static text', goo.object)
function goo.text:initialize( parent )
	super.initialize(self,parent)
	self.text = "no text"
	self.color = {0,0,0,255}
end
function goo.text:draw()
	love.graphics.setColor( unpack(self.color) )
	love.graphics.print( self.text, self.x, self.y )
end
function goo.text:setText( text )
	self.text = text or ''
end
function goo.text:getText()
	return self.text
end

return goo.text

Re: Goo: Gui and Animation library.

Posted: Sat Dec 04, 2010 5:49 pm
by TheAncientGoat
Anyone still maintaining this lib? I added a getAbsoluteSize method sothat you can centre align buttons.

in goo.lua:

Code: Select all

function goo.base:getAbsoluteSize() return 0,0 end

function goo.object:getAbsoluteSize( w, h )
	local w, h = w or self.w, h or self.h
	return (w*self.parent.xscale), (h*self.parent.yscale)
not exactly groundbreaking stuff, but it's a useful little function

Re: Goo: Gui and Animation library.

Posted: Thu Jan 20, 2011 12:37 pm
by qubodup
Would anybody mind forking https://github.com/perky/Goo/network and adding the changes that have been added in this thread? That would be super-handy-dandy.. :)

Re: Goo: Gui and Animation library.

Posted: Thu Jan 20, 2011 2:35 pm
by ljdp
Tell you what. I've got this afternoon free, i'll just update the main repository :)

Edit: New version is under 'Experimental' branch for now.