Classes

Concepts

Libraries

advertisement »

ambientSounds »

bitser »

contentPoints »

eventBoxText »

factValidity »

frameBuffer »

officeBuildingInserter »

priorityRenderer »

randomEvents »

scaling »

spritesheetParser »

statusIcons »

test3 »

util »

Objects

register

Description

Used for registering new UI element classes.

Arguments

1 string id

The ID of the new UI element.

2 table elementClass

The table containing all the variables and classes necessary for this method.

3 string inherit

The ID of another UI element that this element should inherit. (Optional)

Returns


Notice: Undefined offset: 1 in /var/www/vhosts/gamedevstudiogame.com/httpdocs/templates/method_view.phtml on line 24

1 Nothing.

Example

-- the "Panel" element taken from engine/gui/panel.lua


-- register the panel here, since most (if not all) GUI elements will use it as a base


local PANEL = {}
PANEL.canPropagateKeyPress = true
PANEL.drawColor = color(0, 0, 0, 255)

function PANEL:init()
	self.shouldDraw = true
	self.alpha = 175
end

function PANEL:draw( w, h )
	if not self.shouldDraw then return end
	
	love.graphics.setColor(self.drawColor.r, self.drawColor.g, self.drawColor.b, self.alpha)
	love.graphics.rectangle("fill", 0, 0, w, h)
end

gui.register("Panel", PANEL)