Layer

EntityVisualQuadceramic.Layer (Class) → Filter, Fragment, LowRes, Scene, View

A specialized container for organizing and grouping visuals.

Layer extends Quad but is transparent by default, making it ideal for:

  • Grouping related visuals together
  • Creating scrollable areas
  • Implementing UI panels and containers
  • Managing z-ordering of visual groups
  • Applying transforms to multiple visuals at once

Key features:

  • Transparent by default (doesn't render itself)
  • Resize event for responsive layouts
  • Efficient batched resize notifications
  • Can still be made visible with texture/color if needed

Layers are commonly used to organize your scene hierarchy and apply transformations to groups of objects together.

// Create a game layer that can be scrolled
var gameLayer = new Layer();
gameLayer.size(screen.width, screen.height);

// Add game objects to the layer
var player = new Quad();
gameLayer.add(player);

// Scroll the entire game world
gameLayer.x = camera.contentTranslateX;
gameLayer.y = camera.contentTranslateY;

// Create a UI layer that stays fixed
var uiLayer = new Layer();
uiLayer.size(screen.width, screen.height);
uiLayer.depth = 100; // Render on top
See: Quad, Visual

Instance Members

new(): Void

Private Members

sizeDirty: Bool

emitResize(width: Float, height: Float): Void

Emitted when the layer's size changes. Useful for implementing responsive layouts and updating child positions. The event is batched - multiple size changes in the same frame emit only once.

Name Type Description
width Float New width of the layer
height Float New height of the layer

emitResizeIfNeeded(): Void

willEmitResize(width: Float, height: Float): Void

Called before emitting the resize event. Override in subclasses to prepare for size changes.

Name Type Description
width Float New width that will be emitted
height Float New height that will be emitted

didEmitResize(width: Float, height: Float): Void

Called after emitting the resize event. Override in subclasses to perform post-resize updates.

Name Type Description
width Float New width that was emitted
height Float New height that was emitted

Metadata

Name Parameters
:build ceramic.macros.EntityMacro.buildForCompletion()
:autoBuild ceramic.macros.EntityMacro.buildForCompletion()
:build tracker.macros.EventsMacro.build()
:autoBuild tracker.macros.EventsMacro.build()