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
Ticker<TArgs>
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?
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
args
> args: TArgs
Defined in: src/canvas/tickers/classes/TickerBase.ts:85
Arguments to pass to the ticker
Implementation of
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
duration?
> optional duration?: number
Defined in: src/canvas/tickers/classes/TickerBase.ts:86
Duration in seconds to run the ticker
Implementation of
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
priority?
> optional priority?: UPDATE_PRIORITY
Defined in: src/canvas/tickers/classes/TickerBase.ts:87
Priority of the ticker
Implementation of
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
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
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
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
play()
> play(): void
Defined in: src/canvas/tickers/classes/TickerBase.ts:137
Plays the animation.
Returns
void
Implementation of
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
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