diff --git a/src/inputs-controller.ts b/src/inputs-controller.ts index 7b0cb9cb050..652e3d58062 100644 --- a/src/inputs-controller.ts +++ b/src/inputs-controller.ts @@ -51,21 +51,6 @@ export interface InterfaceConfig { const repeatInputDelayMillis = 250; -// Phaser.Input.Gamepad.GamepadPlugin#refreshPads -declare module "phaser" { - namespace Input { - namespace Gamepad { - interface GamepadPlugin { - /** - * Refreshes the list of connected Gamepads. - * This is called automatically when a gamepad is connected or disconnected, and during the update loop. - */ - refreshPads(): void; - } - } - } -} - /** * Manages and handles all input controls for the game, including keyboard and gamepad interactions. * diff --git a/src/main.ts b/src/main.ts index 41cd68afc1e..8a69d3f1b72 100644 --- a/src/main.ts +++ b/src/main.ts @@ -73,75 +73,13 @@ const config: Phaser.Types.Core.GameConfig = { /** * Sets this object's position relative to another object with a given offset - * @param guideObject {@linkcode Phaser.GameObjects.GameObject} to base the position off of - * @param x The relative x position - * @param y The relative y position */ -const setPositionRelative = function (guideObject: any, x: number, y: number) { +const setPositionRelative = function (guideObject: Phaser.GameObjects.GameObject, x: number, y: number) { const offsetX = guideObject.width * (-0.5 + (0.5 - guideObject.originX)); const offsetY = guideObject.height * (-0.5 + (0.5 - guideObject.originY)); this.setPosition(guideObject.x + offsetX + x, guideObject.y + offsetY + y); }; -declare module "phaser" { - namespace GameObjects { - interface Container { - /** - * Sets this object's position relative to another object with a given offset - * @param guideObject {@linkcode Phaser.GameObjects.GameObject} to base the position off of - * @param x The relative x position - * @param y The relative y position - */ - setPositionRelative(guideObject: any, x: number, y: number): void; - } - interface Sprite { - /** - * Sets this object's position relative to another object with a given offset - * @param guideObject {@linkcode Phaser.GameObjects.GameObject} to base the position off of - * @param x The relative x position - * @param y The relative y position - */ - setPositionRelative(guideObject: any, x: number, y: number): void; - } - interface Image { - /** - * Sets this object's position relative to another object with a given offset - * @param guideObject {@linkcode Phaser.GameObjects.GameObject} to base the position off of - * @param x The relative x position - * @param y The relative y position - */ - setPositionRelative(guideObject: any, x: number, y: number): void; - } - interface NineSlice { - /** - * Sets this object's position relative to another object with a given offset - * @param guideObject {@linkcode Phaser.GameObjects.GameObject} to base the position off of - * @param x The relative x position - * @param y The relative y position - */ - setPositionRelative(guideObject: any, x: number, y: number): void; - } - interface Text { - /** - * Sets this object's position relative to another object with a given offset - * @param guideObject {@linkcode Phaser.GameObjects.GameObject} to base the position off of - * @param x The relative x position - * @param y The relative y position - */ - setPositionRelative(guideObject: any, x: number, y: number): void; - } - interface Rectangle { - /** - * Sets this object's position relative to another object with a given offset - * @param guideObject {@linkcode Phaser.GameObjects.GameObject} to base the position off of - * @param x The relative x position - * @param y The relative y position - */ - setPositionRelative(guideObject: any, x: number, y: number): void; - } - } -} - Phaser.GameObjects.Container.prototype.setPositionRelative = setPositionRelative; Phaser.GameObjects.Sprite.prototype.setPositionRelative = setPositionRelative; Phaser.GameObjects.Image.prototype.setPositionRelative = setPositionRelative; diff --git a/src/typings/phaser/index.d.ts b/src/typings/phaser/index.d.ts new file mode 100644 index 00000000000..f3665768cec --- /dev/null +++ b/src/typings/phaser/index.d.ts @@ -0,0 +1,68 @@ +import "phaser"; + +declare module "phaser" { + namespace GameObjects { + interface GameObject { + width: number; + + height: number; + + originX: number; + + originY: number; + + x: number; + + y: number; + } + + interface Container { + /** + * Sets this object's position relative to another object with a given offset + */ + setPositionRelative(guideObject: any, x: number, y: number): void; + } + interface Sprite { + /** + * Sets this object's position relative to another object with a given offset + */ + setPositionRelative(guideObject: any, x: number, y: number): void; + } + interface Image { + /** + * Sets this object's position relative to another object with a given offset + */ + setPositionRelative(guideObject: any, x: number, y: number): void; + } + interface NineSlice { + /** + * Sets this object's position relative to another object with a given offset + */ + setPositionRelative(guideObject: any, x: number, y: number): void; + } + interface Text { + /** + * Sets this object's position relative to another object with a given offset + */ + setPositionRelative(guideObject: any, x: number, y: number): void; + } + interface Rectangle { + /** + * Sets this object's position relative to another object with a given offset + */ + setPositionRelative(guideObject: any, x: number, y: number): void; + } + } + + namespace Input { + namespace Gamepad { + interface GamepadPlugin { + /** + * Refreshes the list of connected Gamepads. + * This is called automatically when a gamepad is connected or disconnected, and during the update loop. + */ + refreshPads(): void; + } + } + } +}