@drincs/pixi-vn
Version:
Pixi'VN is a npm package that provides various features for creating visual novels.
71 lines (68 loc) • 3.6 kB
TypeScript
import { UPDATE_PRIORITY, Ticker as Ticker$1 } from 'pixi.js';
import { TickerIdType } from '../../types/TickerIdType.js';
import TickerArgs from '../../interface/TickerArgs.js';
import Ticker from '../../interface/Ticker.js';
/**
* A class is used to create a ticker element to add into a Pixi Application.
* You can use {@link canvas.addTicker()} to add this element into the application.
* This class should be extended and the fn method should be overridden.
* You must use the {@link tickerDecorator} to register the ticker in the game.
* In Ren'Py is a transform.
* @example
* ```typescript
* \@tickerDecorator() // this is equivalent to tickerDecorator("RotateTicker")
* export class RotateTicker extends TickerBase<{ speed?: number }> {
* override fn(
* t: TickerValue, // the ticker that is calling this method
* args: { // the arguments that you passed when you added the ticker
* speed?: number,
* },
* aliases: string[], // the aliases of the canvas elements that are connected to this ticker
* tickerId: string, // the id of the ticker. You can use this to get the ticker from the canvas.currentTickers
* ): void {
* let speed = args.speed === undefined ? 0.1 : args.speed
* aliases.forEach((alias) => {
* let element = canvas.find(alias)
* if (element && element instanceof Container) {
* if (clockwise)
* element.rotation += speed * t.deltaTime
* else
* element.rotation -= speed * t.deltaTime
* }
* })
* }
* }
* ```
*/
declare class TickerBase<TArgs extends TickerArgs> implements Ticker<TArgs> {
/**
* @param args The arguments that you want to pass to the ticker.
* @param duration The duration of the ticker in seconds. If is undefined, the step will end only when the animation is finished (if the animation doesn't have a goal to reach then it won't finish). @default undefined
* @param priority The priority of the ticker. @default UPDATE_PRIORITY.NORMAL
*/
constructor(args: TArgs, duration?: number, priority?: UPDATE_PRIORITY);
/**
* Get the id of the ticker. This variable is used in the system to get the ticker by id, {@link getTickerInstanceById}
*/
id: TickerIdType;
args: TArgs;
duration?: number;
priority?: UPDATE_PRIORITY;
/**
* The method that will be called every frame.
* This method should be overridden and you can use {@link canvas.add()} to get the canvas element of the canvas, and edit them.
* @param _ticker The ticker that is calling this method
* @param _args The arguments that you passed when you added the ticker
* @param _alias The alias of the canvas elements that are connected to this ticker
* @param _tickerId The id of the ticker. You can use this to get the ticker from the {@link canvas.currentTickers}
*/
fn(_ticker: Ticker$1, _args: TArgs, _alias: string | string[], _tickerId: string): void;
/**
* This method is called when the ticker is added to the canvas.
* @param alias The alias of the canvas elements that are connected to this ticker
* @param tickerId The id of the ticker. You can use this to get the ticker from the {@link canvas.currentTickers}
* @param options The options that you passed when you added the ticker
*/
onEndOfTicker(_alias: string | string[], tickerId: string, args: TArgs): void;
}
export { TickerBase as default };