UNPKG

@drincs/pixi-vn

Version:

Pixi'VN is a npm package that provides various features for creating visual novels.

31 lines (28 loc) 1.1 kB
import CanvasEventNamesType from '../types/CanvasEventNamesType.mjs'; import { EventIdType } from '../types/EventIdType.mjs'; /** * CanvasEvent is a class that is used to create a pixi event, and connect it to a canvas element, with on(). * This class should be extended and the fn method should be overridden. * You must use the {@link eventDecorator} to register the event in the game. * @example * ```typescript * \@eventDecorator() // this is equivalent to eventDecorator("EventTest") * export class EventTest extends CanvasEvent<CanvasSprite> { * override fn(event: CanvasEventNamesType, sprite: CanvasSprite): void { * if (event === 'pointerdown') { * sprite.scale.x *= 1.25; * sprite.scale.y *= 1.25; * } * } * } * ``` */ declare class CanvasEvent<C> { constructor(); fn(_event: CanvasEventNamesType, _element: C): void; /** * Get the id of the event. This variable is used in the system to get the event by id, {@link getEventInstanceById} */ id: EventIdType; } export { CanvasEvent as default };