Function: add()
> add<M, T>(target, options?): void
Defined in: src/canvas/decorators/canvas-element-decorator.ts:141
Register a canvas component in the game.
Type Parameters
M
M extends CanvasBaseItemMemory
T
T extends typeof CanvasBaseItem
Parameters
target
T
The class of the canvas component.
options?
Options for the canvas component.
copyProperty?
(component, memory) => void | Promise<void>
Function to copy the properties of the canvas component. This function is used when to copy the properties of the canvas component into another instance of the same canvas component. This function is used into canvas.copyCanvasElementProperty to copy the properties of the canvas component.
getInstance?
(canvasClass, memory) => CanvasBaseItem<M> | Promise<CanvasBaseItem<M>>
Function to get the instance of the canvas component. If not set, it will use the default constructor of the class. This function is used into canvas.restore to restore the canvas.
name?
string
Name of the canvas component. If the name is already registered, it will show a warning
Default
target.name
Returns
void