Skip to content

class Texture (client-side)

Available since version: 0.3.0

Constructor

Texture.new(number x, number y, number width, number height, string file)

Parameters:

  • number x: X position (virtual units).
  • number y: Y position (virtual units).
  • number width: Width (virtual units).
  • number height: Height (virtual units).
  • string file: Texture file path.

Properties

{x, y} position

Gets or sets the texture position in virtual screen units.


{x, y} positionPx

Gets or sets the texture position in pixel coordinates.


{width, height} size

Gets or sets the texture size in virtual screen units.


{width, height} sizePx

Gets or sets the texture size in pixel coordinates.


{x, y, width, height} rect

Gets or sets the texture rectangle in virtual screen units.


{x, y, width, height} rectPx

Gets or sets the texture rectangle in pixel coordinates.


{r, g, b} color

Gets or sets the texture color.


number alpha

Gets or sets the texture alpha (opacity).


boolean visible

Gets or sets whether the texture is rendered.


string file

Gets or sets the texture file path.


Methods

setPosition

Sets the texture position in virtual screen units.

void setPosition(number x, number y)

Parameters:

  • number x: X position (virtual units).
  • number y: Y position (virtual units).

getPosition

Returns the texture position in virtual screen units.

{x, y} getPosition()

Returns {x, y}:

Table containing x and y (virtual units).


setPositionPx

Sets the texture position in pixel coordinates.

void setPositionPx(number x, number y)

Parameters:

  • number x: X position (pixels).
  • number y: Y position (pixels).

getPositionPx

Returns the texture position in pixel coordinates.

{x, y} getPositionPx()

Returns {x, y}:

Table containing x and y (pixels).


setSize

Sets the texture size in virtual screen units.

void setSize(number width, number height)

Parameters:

  • number width: Width (virtual units).
  • number height: Height (virtual units).

getSize

Returns the texture size in virtual screen units.

{width, height} getSize()

Returns {width, height}:

Table containing width and height (virtual units).


setSizePx

Sets the texture size in pixel coordinates.

void setSizePx(number width, number height)

Parameters:

  • number width: Width (pixels).
  • number height: Height (pixels).

getSizePx

Returns the texture size in pixel coordinates.

{width, height} getSizePx()

Returns {width, height}:

Table containing width and height (pixels).


setRect

Sets the texture rectangle in virtual screen units.

void setRect(number x, number y, number width, number height)

Parameters:

  • number x: X position (virtual units).
  • number y: Y position (virtual units).
  • number width: Width (virtual units).
  • number height: Height (virtual units).

getRect

Returns the texture rectangle in virtual screen units.

{x, y, width, height} getRect()

Returns {x, y, width, height}:

Table containing x,y,width,height (virtual units).


setRectPx

Sets the texture rectangle in pixel coordinates.

void setRectPx(number x, number y, number width, number height)

Parameters:

  • number x: X position (pixels).
  • number y: Y position (pixels).
  • number width: Width (pixels).
  • number height: Height (pixels).

getRectPx

Returns the texture rectangle in pixel coordinates.

{x, y, width, height} getRectPx()

Returns {x, y, width, height}:

Table containing x,y,width,height (pixels).


setColor

Sets the texture color.

void setColor(number r, number g, number b)

Parameters:

  • number r: Red component (0-255).
  • number g: Green component (0-255).
  • number b: Blue component (0-255).

getColor

Returns the texture color.

{r, g, b} getColor()

Returns {r, g, b}:

Table containing r,g,b (0-255).


setAlpha

Sets the texture alpha (opacity).

void setAlpha(number alpha)

Parameters:

  • number alpha: Opacity value (0-255).

getAlpha

Returns the texture alpha (opacity).

number getAlpha()

Returns number:

Opacity value (0-255).


setFile

Sets the texture file name.

void setFile(string file)

Parameters:

  • string file: Texture file name.

getFile

Returns the texture file name.

string getFile()

Returns string:

Texture file name.


setVisible

Sets whether the texture should be rendered.

void setVisible(boolean visible)

Parameters:

  • boolean visible: True to render, false to hide.

getVisible

Returns whether the texture is visible.

boolean getVisible()

Returns boolean:

True if visible.


top

Moves the texture to the top of the render order.

void top()

Callbacks

No callbacks.