LogoPixi’VN
indexClasses

Abstract Class: TickerBase<TArgs>

Defined in: src/canvas/tickers/classes/TickerBase.ts:44

A class is used to create a ticker element to add into a Pixi Application. You can use () to add this element into the application. This class should be extended and the fn method should be overridden. You must use the tickerDecorator to register the ticker in the game. In Ren'Py is a transform.

Example

\@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
                }
            })
    }
}

Type Parameters

TArgs

TArgs extends TickerArgs

The type of the arguments that you want to pass to the ticker.

Implements

Constructors

Constructor

> new TickerBase<TArgs>(args, options?): TickerBase<TArgs>

Defined in: src/canvas/tickers/classes/TickerBase.ts:49

Parameters

args

TArgs

The arguments that you want to pass to the ticker.

options?

The options of the ticker.

canvasElementAliases?

string[]

The aliases of the canvas elements that are connected to this ticker. This is used by the system to know which canvas elements are connected to this ticker, and to pass them to the fn method.

Default

[]
duration?

number

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
id?

string

The id of the ticker. This param is used by the system when will ber restoring the tickers from a save. If not provided, a random id will be generated.

Default

undefined
priority?

UPDATE_PRIORITY

The priority of the ticker.

Default

UPDATE_PRIORITY.NORMAL

Returns

TickerBase<TArgs>

Properties

alias

> readonly alias: string

Defined in: src/canvas/tickers/classes/TickerBase.ts:83

Get the alias of the ticker class. This variable is used in the system to get the ticker class by id, RegisteredTickers.getInstance

Implementation of

Ticker.alias


args

> args: TArgs

Defined in: src/canvas/tickers/classes/TickerBase.ts:85

Arguments to pass to the ticker

Implementation of

Ticker.args


canvasElementAliases

> canvasElementAliases: string[] = []

Defined in: src/canvas/tickers/classes/TickerBase.ts:89

The aliases of the canvas elements that are connected to this ticker

Implementation of

Ticker.canvasElementAliases


duration?

> optional duration?: number

Defined in: src/canvas/tickers/classes/TickerBase.ts:86

Duration in seconds to run the ticker

Implementation of

Ticker.duration


fnValue?

> protected optional fnValue?: () => void

Defined in: src/canvas/tickers/classes/TickerBase.ts:115

Returns

void


id

> readonly id: string

Defined in: src/canvas/tickers/classes/TickerBase.ts:84

The id of the ticker. Must be unique for each ticker instance.

Implementation of

Ticker.id


priority?

> optional priority?: UPDATE_PRIORITY

Defined in: src/canvas/tickers/classes/TickerBase.ts:87

Priority of the ticker

Implementation of

Ticker.priority


ticker

> protected ticker: Ticker

Defined in: src/canvas/tickers/classes/TickerBase.ts:88

Accessors

paused

Get Signature

> get paused(): boolean

Defined in: src/canvas/tickers/classes/TickerBase.ts:140

Checks if the ticker is paused.

Returns

boolean

true if the ticker is paused, false otherwise.

Checks if the ticker is paused.

Implementation of

Ticker.paused

Methods

complete()

> complete(_options?): void

Defined in: src/canvas/tickers/classes/TickerBase.ts:116

Completes the animation and applies the final state.

Parameters

_options?
ignoreTickerSteps?

boolean

Returns

void

Implementation of

Ticker.complete


fn()

> abstract fn(_ticker, _args, _alias, _tickerId): void

Defined in: src/canvas/tickers/classes/TickerBase.ts:109

The method that will be called every frame. This method should be overridden and you can use () to get the canvas element of the canvas, and edit them.

Parameters

_ticker

Ticker

The ticker that is calling this method

_args

TArgs

The arguments that you passed when you added the ticker

_alias

string | string[]

The alias 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

Returns

void


pause()

> pause(): void

Defined in: src/canvas/tickers/classes/TickerBase.ts:134

Pauses the animation.

Returns

void

Implementation of

Ticker.pause


play()

> play(): void

Defined in: src/canvas/tickers/classes/TickerBase.ts:137

Plays the animation.

Returns

void

Implementation of

Ticker.play


start()

> start(): void

Defined in: src/canvas/tickers/classes/TickerBase.ts:127

Starts the ticker. This will start the ticker and begin the animation.

Returns

void

Implementation of

Ticker.start


stop()

> stop(): void

Defined in: src/canvas/tickers/classes/TickerBase.ts:119

Stops the animation at its current state, and prevents it from resuming when the animation is played again.

Returns

void

Implementation of

Ticker.stop