2021-05-12 09:13:25 +02:00
|
|
|
import type Phaser from "phaser";
|
2021-02-03 23:28:46 +01:00
|
|
|
|
|
|
|
export type CursorKey = {
|
2021-08-27 10:34:03 +02:00
|
|
|
isDown: boolean;
|
|
|
|
};
|
2021-02-03 23:28:46 +01:00
|
|
|
|
2021-08-27 10:34:03 +02:00
|
|
|
export type Direction = "left" | "right" | "up" | "down";
|
2021-02-03 23:28:46 +01:00
|
|
|
|
|
|
|
export interface CursorKeys extends Record<Direction, CursorKey> {
|
|
|
|
left: CursorKey;
|
|
|
|
right: CursorKey;
|
|
|
|
up: CursorKey;
|
|
|
|
down: CursorKey;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface IVirtualJoystick extends Phaser.GameObjects.GameObject {
|
|
|
|
y: number;
|
|
|
|
x: number;
|
2021-01-23 02:21:16 +01:00
|
|
|
forceX: number;
|
|
|
|
forceY: number;
|
2021-02-03 23:28:46 +01:00
|
|
|
visible: boolean;
|
|
|
|
createCursorKeys: () => CursorKeys;
|
|
|
|
}
|
|
|
|
|
2021-08-27 10:34:03 +02:00
|
|
|
export type RequireOnlyOne<T, keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, keys>> &
|
|
|
|
{
|
|
|
|
[K in keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<keys, K>, undefined>>;
|
|
|
|
}[keys];
|