Texture Sprite
2D textured sprite quad with texture mapping, tinting, origin offsets, and flipping.
Type: TextureNode · Category: Graphics & Rendering · Also found as: texture, sprite
Properties
Section titled “Properties”| Property | Type | Default | Description |
|---|---|---|---|
tint |
color | #ffffffff |
Multiplies the texture’s colours (white = unchanged; alpha fades it). |
Plus the common properties every node has.
Lua methods
Section titled “Lua methods”Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.
TextureNode:set_texture(path)
Section titled “TextureNode:set_texture(path)”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")pathTexturePath|stringProject-relative texture path
Returns boolean ok
TextureNode:get_property(path)
Section titled “TextureNode:get_property(path)”Reads an Inspector property by its path (vectors and colours as tables); “script.
local value = self.node:get_property("tint")pathTextureNodeProperty|string
Returns any
TextureNode:set_property(path, value, y)
Section titled “TextureNode:set_property(path, value, y)”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.
self.node:set_property("tint", "#ff8800")pathTextureNodeProperty|stringvalueanyy?number
TextureNode:texture_get_size()
Section titled “TextureNode:texture_get_size()”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
TextureNode:texture_set_origin(ox, oy)
Section titled “TextureNode:texture_set_origin(ox, oy)”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)oxnumberOrigin X in pixelsoynumberOrigin Y in pixels
TextureNode:texture_get_path()
Section titled “TextureNode:texture_get_path()”Gets the file path string from which this texture was loaded.
local path = self.node:get_node("Sprite"):texture_get_path()Returns string
In a scene file
Section titled “In a scene file”{ "type": "TextureNode", "name": "TextureSprite", "position": [ 0, 0 ], "properties": { "tint": "#ffffffff" }}