@drincs/pixi-vn
Version:
Pixi'VN is a npm package that provides various features for creating visual novels.
92 lines (89 loc) • 3.53 kB
TypeScript
import { Container as Container$1, ContainerOptions, ContainerEvents, EventEmitter } from 'pixi.js';
import CanvasEventNamesType from '../../types/CanvasEventNamesType.js';
import CanvasEvent from '../CanvasEvent.js';
import CanvasBaseItem from './CanvasBaseItem.js';
import ContainerChild from '../../types/ContainerChild.js';
import ContainerMemory from '../../interface/canvas/memory/ContainerMemory.js';
import '../../types/EventIdType.js';
import '../../interface/canvas/memory/CanvasBaseItemMemory.js';
/**
* This class is a extension of the [PIXI.Container class](https://pixijs.com/8.x/examples/basic/container), 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 container = new Container();
* canvas.add(container);
* const texture = await Assets.load('https://pixijs.com/assets/bunny.png');
* for (let i = 0; i < 25; i++)
* {
* const bunny = new Sprite(texture);
* bunny.x = (i % 5) * 40;
* bunny.y = Math.floor(i / 5) * 40;
* container.addChild(bunny);
* }
* ```
*/
declare class Container<C extends ContainerChild = ContainerChild, Memory extends ContainerMemory = ContainerMemory> extends Container$1<C> implements CanvasBaseItem<Memory> {
constructor(options?: ContainerOptions<C>);
pixivnId: string;
get memory(): Memory;
set memory(_value: Memory);
setMemory(value: Memory): Promise<void>;
protected importChildren(value: Memory): 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<Container> {
* override fn(event: CanvasEventNamesType, container: Container): void {
* if (event === 'pointerdown') {
* container.scale.x *= 1.25;
* container.scale.y *= 1.25;
* }
* }
* }
* ```
*
* ```typescript
* const container = new Container();
*
* container.eventMode = 'static';
* container.cursor = 'pointer';
* container.onEvent('pointerdown', EventTest);
*
* canvas.add("container", container);
* ```
*/
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 setMemoryContainer<T extends Container$1>(element: T | Container$1, memory: ContainerOptions | {}, options?: {
ignoreScale?: boolean;
end?: () => Promise<void>;
}): Promise<void>;
export { Container as default, setMemoryContainer };