SpriteAnimation.lua
Tile.lua
Neo3D.lua
QuadTree.lua
Widget.lua
Sprite.lua
Collision.lua
OEntity.lua
Button.lua
Graphics2D.lua
InputField.lua
LuaUnit.lua
Tests.lua
OCamera.lua
Object3d.lua
class.lua
OLight.lua
SpriteSheet.lua
OSound.lua
Utils.lua
Canvas.lua
Label.lua
Api.lua

The widget class

The widget class represents the base class for every widget.
It contains the most basic functionality shared by every widget type like
translating the position or changing the rotation.

Keep in mind that a Widget object does not refer to an existing C++ widget and is just used
to provide common methods for other Widget based classes!


Class members

widget: The native widget handle used by the C++ backend.

Do not write to these directly! Use the suitable methods for that!

Parameter

position[1]

The X position of the widget

position[2]

The Y position of the widget

height

The height of the widget

width

The width of the widget

rotation

The current rotation of the widget.

Widget(x,y,w,h,text)

Creates a new Widget object.

Parameter

x

The x position on the canvas

y

The y position on the canvas

w

The width of the widget

h

The height of the widget

text

The label of the widget. (optional)

function Widget:setScale(scale)

Sets the scale of the widget

Parameter

scale

A vec2 with the X and Y scale factor.

function Widget:setPosition(x,y)

Sets the current position of the widget

Parameter

x

The new X position

y

The new Y position

function Widget:setRotation(r)

Sets the current rotation of the widget

Parameter

r

The new rotation angle

function Widget:rotate(angle)

Rotates the widget by an angle.

Parameter

angle

The angle to rotate by

function Widget:translate(x,y)

Translates the widget by the given coordinates relative to the current position.

Parameter

x

The X offset

y

The Y offset

function Widget:getPosition()

Gets the current position of the widget.

Parameter

x

The X cordonat

y

The Y cordonat

function Widget:getSize()

Returns the width and height of this object.

Return: A vec2 with the width and the height.

function Widget:getLabel()

Retrieves the current label of the widget.

Return: The label as a string.

function Widget:setLabel(label)

Changes the current label of the widget.

Parameter

label

The new label.

function Widget:setVisible(value)

Changes the widget visibility

Parameter

value

A boolean indicating if the widget should be visible or not.

function Widget:isVisible()

Returns if the widget is turned visible.

Return: A boolean value.