advertisement »

ambientSounds »

bitser »

contentPoints »

eventBoxText »

factValidity »

frameBuffer »

officeBuildingInserter »

priorityRenderer »

randomEvents »

scaling »

spritesheetParser »

statusIcons »

test3 »

util »




Creates a new instance of the UI element of the specified class


1 string class

The class name of the UI object to instantiate, which was previously registered via gui.register.

2 table parent (optional)

The UI element to parent it to.

3 any various

All arguments passed into the method after this will be passed into the instantiated object's :init method.


1 table

object-The instantiated UI object.


local frame = gui.create("Frame") -- instantiate the Frame UI element class

frame:setSize(500, 600) -- set width to 500 and height to 600. Scaled along with the screen resolution

frame:setPos(5, 5) -- set the position of the UI element to X/Y 5, 5, relative to the screen, because it is not parented to anything

frame:setPos(_S(5), _S(5)) -- set the position of the UI element to X/Y 5, 5 scaled with the resolution of the game

frame:setFont("bh24") -- set the font to use for the title of the frame

frame:setText("My Frame")

local label = gui.create("Label", frame) -- create an instance of the Label UI element and parent it to the 'frame' UI element instantiated above

label:setFont("pix20") -- set the font to use with the label

label:wrapText(frame.w - _S(10, "This is very long text, but using the :wrapText method it will be wrapped to the width specified in the first argument of this function call.")
label:setPos(_S(5), _S(35)) -- set the position of the label element relative to the parent's base position

frame:center() -- center the element to the screen based on it's current size

frameController:push(frame) -- push the frame object into the frameController, which takes care of displaying frames consequently