UNPKG

@drincs/pixi-vn

Version:

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

81 lines (78 loc) 2.88 kB
import { Text as Text$1, TextOptions, ContainerEvents, ContainerChild, EventEmitter } from 'pixi.js'; import CanvasEventNamesType from '../../types/CanvasEventNamesType.js'; import CanvasEvent from '../CanvasEvent.js'; import CanvasBaseItem from './CanvasBaseItem.js'; import TextMemory from '../../interface/canvas/memory/TextMemory.js'; import '../../types/EventIdType.js'; import '../../interface/canvas/memory/CanvasBaseItemMemory.js'; /** * This class is a extension of the [PIXI.Text class](https://pixijs.com/8.x/examples/text/pixi-text), it has the same properties and methods, * but it has the ability to be saved and loaded by the Pixi’VN library. * @example * ```typescript * const text = new Text(); * text.text = "Hello World" * canvas.add("text", text); * ``` */ declare class Text extends Text$1 implements CanvasBaseItem<TextMemory> { constructor(options?: TextOptions); pixivnId: string; get memory(): TextMemory; set memory(_value: TextMemory); setMemory(value: TextMemory): Promise<void>; private _onEvents; get onEvents(): { [name: string]: string; }; /** * is same function as on(), but it keeps in memory the children. * @param event The event type, e.g., 'click', 'mousedown', 'mouseup', 'pointerdown', etc. * @param eventClass The class that extends CanvasEvent. * @returns * @example * ```typescript * \@eventDecorator() * export class EventTest extends CanvasEvent<Text> { * override fn(event: CanvasEventNamesType, text: Text): void { * if (event === 'pointerdown') { * text.scale.x *= 1.25; * text.scale.y *= 1.25; * } * } * } * ``` * * ```typescript * const text = new Text(); * text.text = "Hello World" * * text.eventMode = 'static'; * text.cursor = 'pointer'; * text.onEvent('pointerdown', EventTest); * * canvas.add("text", text); * ``` */ onEvent<T extends typeof CanvasEvent<typeof this>>(event: CanvasEventNamesType, eventClass: T): this; /** * on() does not keep in memory the event class, use onEvent() instead * @deprecated * @private * @param event * @param fn * @param context */ on<T extends keyof ContainerEvents<ContainerChild> | keyof { [K: symbol]: any; [K: {} & string]: any; }>(event: T, fn: (...args: EventEmitter.ArgumentMap<ContainerEvents<ContainerChild> & { [K: symbol]: any; [K: {} & string]: any; }>[Extract<T, keyof ContainerEvents<ContainerChild> | keyof { [K: symbol]: any; [K: {} & string]: any; }>]) => void, context?: any): this; } declare function setMemoryText(element: Text, memory: TextMemory | {}): Promise<void>; export { Text as default, setMemoryText };