@drincs/pixi-vn
Version:
Pixi'VN is a npm package that provides various features for creating visual novels.
83 lines (80 loc) • 3.13 kB
text/typescript
import { Text, TextOptions, ContainerEvents, ContainerChild, EventEmitter } from 'pixi.js';
import ICanvasTextMemory from '../../interface/canvas/ICanvasTextTextMemory.mjs';
import CanvasEventNamesType from '../../types/CanvasEventNamesType.mjs';
import CanvasEvent from '../CanvasEvent.mjs';
import CanvasBase from './CanvasBase.mjs';
import '../../types/EventIdType.mjs';
import '../../interface/canvas/ICanvasBaseMemory.mjs';
declare const CANVAS_TEXT_ID = "CanvasText";
/**
* 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 CanvasText();
* text.text = "Hello World"
* GameWindowManager.addCanvasElement("text", text);
* ```
*/
declare class CanvasText extends Text implements CanvasBase<ICanvasTextMemory> {
constructor(options?: TextOptions);
pixivnId: string;
get memory(): ICanvasTextMemory;
set memory(value: ICanvasTextMemory);
private _onEvents;
get onEvents(): {
[name: string]: string;
[name: symbol]: 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<CanvasText> {
* override fn(event: CanvasEventNamesType, text: CanvasText): void {
* if (event === 'pointerdown') {
* text.scale.x *= 1.25;
* text.scale.y *= 1.25;
* }
* }
* }
* ```
*
* ```typescript
* const text = new CanvasText();
* text.text = "Hello World"
*
* text.eventMode = 'static';
* text.cursor = 'pointer';
* text.onEvent('pointerdown', EventTest);
*
* GameWindowManager.addCanvasElement("text", text);
* ```
*/
onEvent<T extends CanvasEventNamesType, T2 extends typeof CanvasEvent<typeof this>>(event: T, eventClass: T2): 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 getMemoryText<T extends CanvasText>(element: T | CanvasText): ICanvasTextMemory;
declare function setMemoryText(element: CanvasText, memory: ICanvasTextMemory): void;
export { CANVAS_TEXT_ID, CanvasText as default, getMemoryText, setMemoryText };