Skip to content

Tool beta ​

Interface of @v12-engine/editor

ts
export interface Tool

What a click on the map does while it is picked: selecting, putting things down, a brush. The editor has one of each kind, hands the picked one the main button, the keys nothing else took, and every frame, and knows nothing of what it does with them. A tool changes the map through the MapEditor only, so that everything it does can be undone

Members ​

busy ​

ts
readonly busy?: boolean;

In the middle of something: a drag, a stroke. The pointer is the tool's until it ends

cancel ​

ts
cancel?(): void;

Stops: the pointer was taken away, Escape, undo, another tool was picked. What was in the middle of being done is put back, and what the tool shows is taken away

cursor ​

ts
readonly cursor: 'arrow' | 'target';

What the pointer looks like over the map

dispose ​

ts
dispose?(): void;

The editor is closed: what the tool made in the scene goes with it

escape ​

ts
escape?(): boolean;

Escape, when nothing is in the middle of being done: true when the tool took it, to let go of what it picked

frame ​

ts
frame?(ground: Vec2 | null, dt: number): {
        point: Vec2;
        radius: number;
    } | void;

Every frame, with the ground under the pointer and the seconds since the last one: what goes on while the button is held, and what the tool shows. Returns where it is changing the ground just now, if it is

key ​

ts
key?(event: KeyboardEvent): boolean;

A key that is none of the editor's actions (editor.keys), nor one of this tool's own (GameToolDef.actions, which are asked first and are the way to give a tool keys the user can see and move). True when the tool took it

pointerDown ​

ts
pointerDown?(pointer: ToolPointer): void;

The main button went down

pointerMove ​

ts
pointerMove?(pointer: ToolPointer): void;

The pointer moved, whether or not the button is down

pointerUp ​

ts
pointerUp?(pointer: ToolPointer): void;

The main button was let go