Skip to content

Texture

Loads an image file (PNG, JPG, WebP) from the mounted project into a GPU texture. Used by Sprite. The path is resolved inside the game’s asset bundle (the same place Resource and shaders load from).

Returns: Texture — A texture handle (check valid).

Parameters:

  • path (String) — Image path within the mounted project, e.g. "textures/hero.png".
import "engine" for Texture
var tex = Texture.load("textures/hero.png")
if (!tex.valid) System.print("failed to load")
  • width — Image width in pixels (0 if the load failed).
  • height — Image height in pixels.
  • validtrue if the image loaded successfully.
System.print("%(tex.width) x %(tex.height)")

Textures are cached by the renderer; loading the same path is cheap. See Sprite for drawing a texture as a billboarded quad.