Function: canvasComponentDecorator()
> canvasComponentDecorator<M, T>(options?): (target) => void
Defined in: src/canvas/decorators/canvas-element-decorator.ts:53
Is a decorator that register a canvas component in the game.
Type Parameters
M
M extends CanvasBaseItemMemory
T
T extends typeof CanvasBaseItem
Parameters
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
The id used by Pixi’VN to refer to this class (must be unique). If you don't pass the id, the class name will be used as the id.
Default
target.nameReturns
(target) => void
Example
const ALIEN_TINTING_TEST_ID = "AlienTintingTest";
@canvasComponentDecorator({
name: ALIEN_TINTING_TEST_ID,
})
class AlienTintingTest extends Sprite<IAlienTintingMemory> {
readonly pixivnId: string = CANVAS_SPINE_ID;
override get memory() {
// ...
}
override async setMemory(memory: IAlienTintingMemory) {
// ...
}
// ...
}