ViewModel
Since 0.6
Signature
export class ViewModel {
readonly config: ViewModelConfig
readonly screen: string
offset: Vec2 = [0, 0]
constructor(config: ViewModelConfig)
show(ctx: Ctx, ...names: string[]): void
shown(): string[]
update(ctx: Ctx, bob: BobState | null): void
hide(ctx: Ctx): void
box(name: string, offset: Vec2 = this.offset): [number, number, number, number]
}
Import: import { ViewModel } from "@argus/gameplay"
Members
| Member | Signature | Description |
|---|---|---|
config | readonly config: ViewModelConfig | |
screen | readonly screen: string | |
offset | offset: Vec2 = [0, 0] | The bob offset last drawn, in virtual pixels. |
constructor | constructor(config: ViewModelConfig) | |
show | show(ctx: Ctx, ...names: string[]): void | Draw exactly these frames from now on. An unknown name throws, naming the ones there are. |
shown | shown(): string[] | The frames drawn now. |
update | update(ctx: Ctx, bob: BobState | null): void | Once a tick, after the camera rig: put the screen up when play is live, and place the frames. |
hide | hide(ctx: Ctx): void | Stop drawing until the next update: the view is not first-person any more. |
box | box(name: string, offset: Vec2 = this.offset): [number, number, number, number] | Where a frame's box sits on the canvas, in percent: [left, top, width, height]. |