Skip to main content
A Layer represents a single layer in a sprite’s layer hierarchy.

Properties

id
number
Unique layer identifier.
sprite
Sprite
Parent sprite.
parent
Layer | Sprite
Parent layer group or sprite.
layers
array
Child layers (only for layer groups).
stackIndex
number
Position in the layer stack (1-based).
previous
Layer
Previous sibling layer.
next
Layer
Next sibling layer.
name
string
Layer name.
opacity
number
Layer opacity (0-255).
blendMode
BlendMode
Layer blend mode.
isImage
boolean
True if this is an image layer.
isGroup
boolean
True if this is a layer group.
isTilemap
boolean
True if this is a tilemap layer.
isTransparent
boolean
True if this is a transparent layer.
isBackground
boolean
True if this is the background layer.
isEditable
boolean
True if the layer is editable.
isVisible
boolean
True if the layer is visible.
isContinuous
boolean
True if continuous layers are enabled.
isCollapsed
boolean
True if the layer group is collapsed.
isExpanded
boolean
True if the layer group is expanded.
isReference
boolean
True if this is a reference layer.
cels
array
Array of all cels in this layer.
color
Color
Layer color in the timeline.
data
string
User-defined data string.
properties
table
User-defined properties table.
tileset
Tileset
Associated tileset (only for tilemap layers).
uuid
Uuid
Unique identifier (UUID).

Methods

layer:cel(frame)

frame
Frame | number
required
Frame number or Frame object.
Returns the cel at the specified frame.
local cel = layer:cel(1)
if cel then
  print("Cel found at frame 1")
end

Examples

Creating and Naming Layers

local sprite = Sprite(32, 32)
local layer1 = sprite:newLayer()
layer1.name = "Character"
layer1.opacity = 200

local layer2 = sprite:newLayer()
layer2.name = "Background"
layer2.blendMode = BlendMode.MULTIPLY

Working with Layer Groups

local sprite = Sprite(64, 64)
local group = sprite:newGroup()
group.name = "Character Parts"

local headLayer = sprite:newLayer()
headLayer.name = "Head"
headLayer.parent = group

local bodyLayer = sprite:newLayer()
bodyLayer.name = "Body"
bodyLayer.parent = group

group.isCollapsed = true

Iterating Through Layers

local sprite = app.sprite
for i, layer in ipairs(sprite.layers) do
  print(i, layer.name, layer.opacity)
  
  if layer.isGroup then
    for j, child in ipairs(layer.layers) do
      print("  ", j, child.name)
    end
  end
end

Layer Visibility and Properties

local layer = app.layer
layer.isVisible = false
layer.isEditable = true
layer.data = "Custom metadata"
layer.properties = {
  author = "John Doe",
  version = 1
}

Working with Tilemap Layers

local sprite = Sprite(64, 64)
local tilemapLayer = sprite:newLayer()

if tilemapLayer.isTilemap then
  local tileset = tilemapLayer.tileset
  print("Tileset:", tileset.name)
  print("Grid size:", tileset.grid.tileSize)
end

Build docs developers (and LLMs) love