Group
A node holding others: they move, rotate, scale, fade and tint with it.
Example
Section titled “Example”const stars = stage.add(engine.group())stars.add(engine.shape({ type: 'star', r: 40, fill: '#FBD46A' }, { x: 100 }))for (const star of stars.children) star.y += 150 * dtExtends
Section titled “Extends”Extended by
Section titled “Extended by”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Group(
kernel):Group
Parameters
Section titled “Parameters”kernel
Section titled “kernel”Returns
Section titled “Returns”Group
Overrides
Section titled “Overrides”Properties
Section titled “Properties”blend:
Blend
‘add’ for glows and sparks; ‘normal’ otherwise.
Inherited from
Section titled “Inherited from”parent
Section titled “parent”parent:
Group|null
The group the node is in, or null.
Inherited from
Section titled “Inherited from”hitRadius
Section titled “hitRadius”hitRadius:
number|null
Hit tests use a circle of this radius (local units) around the origin instead of the rectangle; null: the rectangle.
Inherited from
Section titled “Inherited from”clip:
ClipRect|null
Clips the node and its children to this rectangle, in the node’s own units (x, y, width, height). While no rotation is above it, the renderer clips on whole pixels without breaking the batch; rotated, it is drawn as a mask. Clips nest (they intersect). Hit tests ignore it.
Example
Section titled “Example”list.clip = { x: 0, y: 0, width: 400, height: 300 } // a scrolling list: move its children, not the clipInherited from
Section titled “Inherited from”mask:
Node|null
Shows the node and its children only where this node is opaque, times its alpha: a circle, a star, a text, any node. The mask is placed as a child of the masked node would be, and is not drawn otherwise (keep it out of the stage). The masked node is drawn into a layer: about two full-canvas composites per mask, so use a few.
Example
Section titled “Example”photo.mask = engine.shape({ type: 'circle', r: 80, fill: '#fff' })Inherited from
Section titled “Inherited from”filters
Section titled “filters”filters:
Filter[] |null
Filters the node and its children go through, in order: tint, brightness, contrast, saturate, grayscale, sepia,
hueRotate, invert, colorMatrix, blur, dropShadow (the same on WebGL and Canvas 2D), shader (WebGL only). The node
is drawn into a layer and composited through them (the filters inside a clip and under a mask). Change their
fields freely (flash.amount = 0.5, tweens); null or [] for none.
Example
Section titled “Example”import { blur, dropShadow } from '@fabiplay/engine'card.filters = [dropShadow(0, 8, 6, 'rgba(0,0,0,0.35)')]background.filters = [blur(6)]Inherited from
Section titled “Inherited from”anchorX
Section titled “anchorX”anchorX:
number
Horizontal anchor, 0–1 of the width: 0 left, 0.5 the middle.
Inherited from
Section titled “Inherited from”anchorY
Section titled “anchorY”anchorY:
number
Vertical anchor, 0–1 of the height: 0 top, 0.5 the middle.
Inherited from
Section titled “Inherited from”children
Section titled “children”
readonlychildren:Node[]
The nodes in it, in drawing order (one shared empty array until the first add). Safe to destroy() them while iterating.
dead:
boolean
@internal: a child was destroyed.
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get x():
number
Position in the parent, stage units.
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set x(
v):void
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get y():
number
Position in the parent, stage units (y downwards).
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set y(
v):void
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”rotation
Section titled “rotation”Get Signature
Section titled “Get Signature”get rotation():
number
Radians, clockwise.
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set rotation(
v):void
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”scaleX
Section titled “scaleX”Get Signature
Section titled “Get Signature”get scaleX():
number
Horizontal scale (negative: mirrored).
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set scaleX(
v):void
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”scaleY
Section titled “scaleY”Get Signature
Section titled “Get Signature”get scaleY():
number
Vertical scale.
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set scaleY(
v):void
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get alpha():
number
0–1, multiplied down the tree.
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set alpha(
v):void
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”visible
Section titled “visible”Get Signature
Section titled “Get Signature”get visible():
boolean
Hidden nodes and their children are not drawn. Hit tests (engine.touched, engine.hits) still see them.
Returns
Section titled “Returns”boolean
Set Signature
Section titled “Set Signature”set visible(
v):void
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”destroyed
Section titled “destroyed”Get Signature
Section titled “Get Signature”get destroyed():
boolean
Set by destroy(): the node is gone (its handle is stale).
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get world():
Mat
The transform to the stage, as of the last draw (or updateWorld): a view on the node store, written in place. Read it when you need it: a view kept across frames stops following the node once the store grows (new arrays).
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get data():
Record<string,any>
Free for the game: speed, state, anything (made on first use).
Returns
Section titled “Returns”Record<string, any>
Set Signature
Section titled “Set Signature”set data(
v):void
Parameters
Section titled “Parameters”Record<string, any>
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get scale():
number
Both scales: reads scaleX, sets scaleX and scaleY.
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set scale(
v):void
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get z():
number
Drawing order among siblings: higher on top (equal: order of adding).
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set z(
v):void
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get tint():
number
A colour multiplied with the node’s pixels (white: none), as 0xRRGGBB or CSS.
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set tint(
v):void
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”anchor
Section titled “anchor”Set Signature
Section titled “Set Signature”set anchor(
v):void
Sets anchorX and anchorY: a number for both, or { x, y }. 0 top-left, 0.5 the middle.
Parameters
Section titled “Parameters”number | { x: number; y: number; }
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get width():
number
Local size, for hit tests and anchors; groups have none.
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set width(
_):void
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”height
Section titled “height”Get Signature
Section titled “Get Signature”get height():
number
Local height, for hit tests and anchors; groups have none.
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set height(
_):void
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”set(
props):this
Sets many fields at once.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”updateWorld()
Section titled “updateWorld()”updateWorld():
Mat
world, computed now from the parents (for hit tests between draws).
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”add<
T>(node, …more):T
Adds nodes (moving them from another group); returns the first, so const s = stage.add(engine.sprite(…)).
Type Parameters
Section titled “Type Parameters”T extends Node
Parameters
Section titled “Parameters”T
…Node[]
Returns
Section titled “Returns”T
remove()
Section titled “remove()”remove(
node):void
Takes a node out of the group (without destroying it).
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
clear()
Section titled “clear()”clear():
void
Destroys every child.
Returns
Section titled “Returns”void
destroy()
Section titled “destroy()”destroy():
void
Destroys the group and every child.
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”draw()
Section titled “draw()”draw(
ctx,alpha,tint):void
Draws the children, in order of z, each placed (its world composed, store.ts place) right before it is drawn, when it or a parent moved. The outermost draw begins a pass; a group in no group drawn inside it (a mask) has been placed anew by its caller, so everything under it is composed.
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”void