File docs/luadoc/goo.object.luadoc

This is the superclass for all goo objects, every object can access it's methods

Functions

goo.object:addToParent (parent) This will hook the object onto the given parent
goo.object:draw () Internal
goo.object:enterHover () Callback function when the mouse enters the bounds of the object.
goo.object:exitHover () Callback function when the mouse exits the bounds of the object.
goo.object:getAbsolutePos (x, y) Gets the absolute position of the object.
goo.object:getAbsoluteScale (x, y) Gets the absolute scale of the object.
goo.object:getRelativePos (x, y) Get the relative position of an object
goo.object:getRelativeScale (xscale, yscale) Get the relative scale of an object
goo.object:initialize (parent) Internal function called from goo.object:new()
goo.object:isMouseHover () is the mouse over the object?
goo.object:mousePressed (x, y, button) Internal
goo.object:mouseReleased (x, y, button) Internal
goo.object:onClick (x, y, button) Callback function when the object is clicked.
goo.object:removeFromParent () This will remove the object from it's parent, it will not remove it completely.
goo.object:resetStyle () Resets the objects style to the one defined in style.lua
goo.object:setColor (colorTable) Internal function used to set the drawing color, used instead of love.graphics.setColor.
goo.object:setOpacity (opacity) Sets the opacity of the object
goo.object:setPos (x, y) Sets the position of the object.
goo.object:setScale (x, y) Sets the scale of the object.
goo.object:setSize (w, h) Sets the size of the position and updates the bounds.
goo.object:setStyle (style) Sets the style of the object.
goo.object:setVisible (visible) Set whether the object should be drawn.
goo.object:sizeToText ()
goo.object:styleDidUpdate () Called after goo.object:setStyle
goo.object:update (dt) Internal
goo.object:updateBounds () Updates the bounds of the object.


Functions

goo.object:addToParent ( parent )

This will hook the object onto the given parent

Parameters

  • parent :goo_object
    the goo object to hook on to

See also:

goo.object:draw ( )

Internal

goo.object:enterHover ( )

Callback function when the mouse enters the bounds of the object.

goo.object:exitHover ( )

Callback function when the mouse exits the bounds of the object.

goo.object:getAbsolutePos ( x, y )

Gets the absolute position of the object.
This function moves up through the entire instance hierarchy returning it's absolute position.
If the parent object is at position 10,10 then obj:getRelativePos(5,5) returns 15,15

Parameters

  • x :number
    the relative x position. (defaults to objects x position)
  • y :number
    the relative y position. (defaults to objects y position)

Return values:

  1. number: absolute x position.
  2. number: absolute y position.
goo.object:getAbsoluteScale ( x, y )

Gets the absolute scale of the object.

Parameters

  • x :number
    the x scale (0-1) (defaults to objects x scale)
  • y :number
    the y scale (0-1) (defaults to objects y scale)

Return values:

  1. number: the absolute x scale (0-1)
  2. number: the absolute y scale (0-1)

See also:

goo.object:getRelativePos ( x, y )

Get the relative position of an object

goo.object:getRelativeScale ( xscale, yscale )

Get the relative scale of an object

goo.object:initialize ( parent )

Internal function called from goo.object:new()

Parameters

  • parent :goo_object
    the parent class to use.

See also:

goo.object:isMouseHover ( )

is the mouse over the object?

Return value:

bool: returns true if the mouse is over the object. false otherwise.

goo.object:mousePressed ( x, y, button )

Internal

goo.object:mouseReleased ( x, y, button )

Internal

goo.object:onClick ( x, y, button )

Callback function when the object is clicked.
If this function exists it will be called when the mousePressed event occurs within the object's bounds.

Parameters

  • x :number
    the absolute x position of the mouse.
  • y :number
    the absolute y position of the mouse.
  • button :string
    the button pressed. 'l' for left, 'r' for right, 'm' for middle.

Usage:

 local button = goo.button:new()
button.name = 'bob'
function button:onClick(x,y,button)
if button == 'l' then
print(self.name .. ' has been clicked')
end
end
-- when the button is clicked with left mouse button it prints:
-- bob has been clicked

goo.object:removeFromParent ( )

This will remove the object from it's parent, it will not remove it completely.
This can be used to unhook an object from it's parent preventing it from inheriting position.
You could also bring an object to the top by calling removeFromParent followed by addToParent but
there is a convient function bringToTop for that.

See also:

goo.object:resetStyle ( )

Resets the objects style to the one defined in style.lua

See also:

goo.object:setColor ( colorTable )

Internal function used to set the drawing color, used instead of love.graphics.setColor.
You should not need to use this unless you're overriding an objects draw method.
It's much like love.graphics.setColor except it takes a table and respects the objects opacity methods.

Parameters

  • colorTable :table
    a table of 3 or 4 color values {r,g,b,a} the values should have no keys. Alpha is optional.
goo.object:setOpacity ( opacity )

Sets the opacity of the object

Parameters

  • opacity :number
    the opacity value (0-255)
goo.object:setPos ( x, y )

Sets the position of the object.

Parameters

  • x :number
    x position
  • y :number
    y position
goo.object:setScale ( x, y )

Sets the scale of the object.

Parameters

  • x :number
    x scale (0-1)
  • y :number
    y scale (0-1)
goo.object:setSize ( w, h )

Sets the size of the position and updates the bounds.

Parameters

  • w :number
    width of the object
  • h :number
    height of the object
goo.object:setStyle ( style )

Sets the style of the object.
each object has a style similar to CSS stylesheets.
You can find these styles in goo/skins/{current skin}/style.lua
This function's purpose is to override the styles defined in style.lua.
To override pass a table with the same keys but you're overridden values.

Parameters

  • style :table
    the style which will override the style set in style.lua

See also:

goo.object:setVisible ( visible )

Set whether the object should be drawn.

Parameters

  • visible :bool
    Should the object be drawn?
goo.object:sizeToText ( )

goo.object:styleDidUpdate ( )

Called after goo.object:setStyle

See also:

goo.object:update ( dt )

Internal

goo.object:updateBounds ( )

Updates the bounds of the object.
The bounds of the object are 4 points, representing the bounding box.
This box is used to detect mouse events.

Valid XHTML 1.0!