Skip to content

Texture Sprite

2D textured sprite quad with texture mapping, tinting, origin offsets, and flipping.

Type: TextureNode · Category: Graphics & Rendering · Also found as: texture, sprite

Property Type Default Description
tint color #ffffffff Multiplies the texture’s colours (white = unchanged; alpha fades it).

Plus the common properties every node has.

Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.

Shows another image on a TextureNode (project-relative path, e.g. a texture script property). Returns false if it isn’t a TextureNode or the file can’t be loaded.

local sprite = self.node:get_node("Sprite"); sprite:set_texture("textures/coin.png")
  • path TexturePath|string Project-relative texture path

Returns boolean ok

Reads an Inspector property by its path (vectors and colours as tables); “script.” reads a field of the node’s script.

local value = self.node:get_property("tint")
  • path TextureNodeProperty|string

Returns any

Sets an Inspector property by its path: vectors as {x, y} or x, y; colours as {r, g, b[, a]} 0..1 or “#rrggbb[aa]”; enums by name; “script.” a field of the node’s script.

self.node:set_property("tint", "#ff8800")
  • path TextureNodeProperty|string
  • value any
  • y? number

Gets the base unscaled pixel width and height of the texture.

local w, h = self.node:get_node("Sprite"):texture_get_size()

Returns number width, number height

Sets the origin (what it rotates and scales around) in pixels of the image; stored as a fraction of it - set_property(“origin”, fx, fy) takes that.

local sprite = self.node:get_node("Sprite"); sprite:texture_set_origin(16, 16)
  • ox number Origin X in pixels
  • oy number Origin Y in pixels

Gets the file path string from which this texture was loaded.

local path = self.node:get_node("Sprite"):texture_get_path()

Returns string

{
"type": "TextureNode",
"name": "TextureSprite",
"position": [
0,
0
],
"properties": {
"tint": "#ffffffff"
}
}