logoBMates

Container

Container is an abstract class that extends Node and serves as a base for objects that can contain child nodes. It provides methods to manage child nodes and handle hit testing.

Check Node for the basic graphics class.

Properties

name: string

The name of the container. The default value is container.

children: ChildType[]

An array of child Node contained within the Container.

Constructor

constructor (attrs: Partial<NodeAttributes> = {})

attrs: Partial<NodeAttributes>

Sets the initial properties of the Node.

Methods

update (dT)

Updates the state of the Node.

NameTypeDescription
dTnumberDelta time

Called before draw().

draw (ctx)

Draws the Node.

NameTypeDescription
ctxCanvasRenderingContext2DRendering context for the drawing surface

Called after update().

add (child)

Adds a child node to the container.

NameTypeDescription
childChildTypeThe child node to add to the container.

remove (child)

Removes a child node from the container.

NameTypeDescription
childChildTypeThe child node to remove from the container.

hitTest (point, e)

Checks if the given point collides with any child nodes in the container.

NameTypeDescription
pointVector2The point to check for collision.
eMouseEventThe mouse event associated with the hit test.
  • Return: Node | null
    • The first child node that collides, or null if no collision occurs.
PREVNodeNEXTLayer
logoBMates