From 9c2abc6b0c080c96dc517ee93471f1f9c57d11b7 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 24 Mar 2021 20:08:02 +0000 Subject: [PATCH] TS Defs update --- types/phaser.d.ts | 25137 ++++++++++++++++++++++---------------------- 1 file changed, 12575 insertions(+), 12562 deletions(-) diff --git a/types/phaser.d.ts b/types/phaser.d.ts index b75d3aad8..cc4a05d6c 100644 --- a/types/phaser.d.ts +++ b/types/phaser.d.ts @@ -631,18 +631,6 @@ declare namespace Phaser { */ function Shuffle(items: G): G; - /** - * Smootherstep is a sigmoid-like interpolation and clamping function. - * - * The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param property The property of the Game Object to interpolate. - * @param min The minimum interpolation value. - * @param max The maximum interpolation value. - * @param inc Should the values be incremented? `true` or set (`false`) Default false. - */ - function SmootherStep(items: G, property: string, min: number, max: number, inc?: boolean): G; - /** * Smoothstep is a sigmoid-like interpolation and clamping function. * @@ -655,6 +643,18 @@ declare namespace Phaser { */ function SmoothStep(items: G, property: string, min: number, max: number, inc?: boolean): G; + /** + * Smootherstep is a sigmoid-like interpolation and clamping function. + * + * The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + * @param property The property of the Game Object to interpolate. + * @param min The minimum interpolation value. + * @param max The maximum interpolation value. + * @param inc Should the values be incremented? `true` or set (`false`) Default false. + */ + function SmootherStep(items: G, property: string, min: number, max: number, inc?: boolean): G; + /** * Takes an array of Game Objects and then modifies their `property` so the value equals, or is incremented, by the * calculated spread value. @@ -5869,148 +5869,6 @@ declare namespace Phaser { */ function DebugHeader(game: Phaser.Game): void; - namespace Events { - /** - * The Game Blur Event. - * - * This event is dispatched by the Game Visibility Handler when the window in which the Game instance is embedded - * enters a blurred state. The blur event is raised when the window loses focus. This can happen if a user swaps - * tab, or if they simply remove focus from the browser to another app. - */ - const BLUR: any; - - /** - * The Game Boot Event. - * - * This event is dispatched when the Phaser Game instance has finished booting, but before it is ready to start running. - * The global systems use this event to know when to set themselves up, dispatching their own `ready` events as required. - */ - const BOOT: any; - - /** - * The Game Context Lost Event. - * - * This event is dispatched by the Game if the WebGL Renderer it is using encounters a WebGL Context Lost event from the browser. - * - * The partner event is `CONTEXT_RESTORED`. - */ - const CONTEXT_LOST: any; - - /** - * The Game Context Restored Event. - * - * This event is dispatched by the Game if the WebGL Renderer it is using encounters a WebGL Context Restored event from the browser. - * - * The partner event is `CONTEXT_LOST`. - */ - const CONTEXT_RESTORED: any; - - /** - * The Game Destroy Event. - * - * This event is dispatched when the game instance has been told to destroy itself. - * Lots of internal systems listen to this event in order to clear themselves out. - * Custom plugins and game code should also do the same. - */ - const DESTROY: any; - - /** - * The Game Focus Event. - * - * This event is dispatched by the Game Visibility Handler when the window in which the Game instance is embedded - * enters a focused state. The focus event is raised when the window re-gains focus, having previously lost it. - */ - const FOCUS: any; - - /** - * The Game Hidden Event. - * - * This event is dispatched by the Game Visibility Handler when the document in which the Game instance is embedded - * enters a hidden state. Only browsers that support the Visibility API will cause this event to be emitted. - * - * In most modern browsers, when the document enters a hidden state, the Request Animation Frame and setTimeout, which - * control the main game loop, will automatically pause. There is no way to stop this from happening. It is something - * your game should account for in its own code, should the pause be an issue (i.e. for multiplayer games) - */ - const HIDDEN: any; - - /** - * The Game Pause Event. - * - * This event is dispatched when the Game loop enters a paused state, usually as a result of the Visibility Handler. - */ - const PAUSE: any; - - /** - * The Game Post-Render Event. - * - * This event is dispatched right at the end of the render process. - * - * Every Scene will have rendered and been drawn to the canvas by the time this event is fired. - * Use it for any last minute post-processing before the next game step begins. - */ - const POST_RENDER: any; - - /** - * The Game Post-Step Event. - * - * This event is dispatched after the Scene Manager has updated. - * Hook into it from plugins or systems that need to do things before the render starts. - */ - const POST_STEP: any; - - /** - * The Game Pre-Render Event. - * - * This event is dispatched immediately before any of the Scenes have started to render. - * - * The renderer will already have been initialized this frame, clearing itself and preparing to receive the Scenes for rendering, but it won't have actually drawn anything yet. - */ - const PRE_RENDER: any; - - /** - * The Game Pre-Step Event. - * - * This event is dispatched before the main Game Step starts. By this point in the game cycle none of the Scene updates have yet happened. - * Hook into it from plugins or systems that need to update before the Scene Manager does. - */ - const PRE_STEP: any; - - /** - * The Game Ready Event. - * - * This event is dispatched when the Phaser Game instance has finished booting, the Texture Manager is fully ready, - * and all local systems are now able to start. - */ - const READY: any; - - /** - * The Game Resume Event. - * - * This event is dispatched when the game loop leaves a paused state and resumes running. - */ - const RESUME: any; - - /** - * The Game Step Event. - * - * This event is dispatched after the Game Pre-Step and before the Scene Manager steps. - * Hook into it from plugins or systems that need to update before the Scene Manager does, but after the core Systems have. - */ - const STEP: any; - - /** - * The Game Visible Event. - * - * This event is dispatched by the Game Visibility Handler when the document in which the Game instance is embedded - * enters a visible state, previously having been hidden. - * - * Only browsers that support the Visibility API will cause this event to be emitted. - */ - const VISIBLE: any; - - } - /** * The core runner class that Phaser uses to handle the game loop. It can use either Request Animation Frame, * or SetTimeout, based on browser support and config settings, to create a continuous loop within the browser. @@ -6268,6 +6126,148 @@ declare namespace Phaser { */ function VisibilityHandler(game: Phaser.Game): void; + namespace Events { + /** + * The Game Blur Event. + * + * This event is dispatched by the Game Visibility Handler when the window in which the Game instance is embedded + * enters a blurred state. The blur event is raised when the window loses focus. This can happen if a user swaps + * tab, or if they simply remove focus from the browser to another app. + */ + const BLUR: any; + + /** + * The Game Boot Event. + * + * This event is dispatched when the Phaser Game instance has finished booting, but before it is ready to start running. + * The global systems use this event to know when to set themselves up, dispatching their own `ready` events as required. + */ + const BOOT: any; + + /** + * The Game Context Lost Event. + * + * This event is dispatched by the Game if the WebGL Renderer it is using encounters a WebGL Context Lost event from the browser. + * + * The partner event is `CONTEXT_RESTORED`. + */ + const CONTEXT_LOST: any; + + /** + * The Game Context Restored Event. + * + * This event is dispatched by the Game if the WebGL Renderer it is using encounters a WebGL Context Restored event from the browser. + * + * The partner event is `CONTEXT_LOST`. + */ + const CONTEXT_RESTORED: any; + + /** + * The Game Destroy Event. + * + * This event is dispatched when the game instance has been told to destroy itself. + * Lots of internal systems listen to this event in order to clear themselves out. + * Custom plugins and game code should also do the same. + */ + const DESTROY: any; + + /** + * The Game Focus Event. + * + * This event is dispatched by the Game Visibility Handler when the window in which the Game instance is embedded + * enters a focused state. The focus event is raised when the window re-gains focus, having previously lost it. + */ + const FOCUS: any; + + /** + * The Game Hidden Event. + * + * This event is dispatched by the Game Visibility Handler when the document in which the Game instance is embedded + * enters a hidden state. Only browsers that support the Visibility API will cause this event to be emitted. + * + * In most modern browsers, when the document enters a hidden state, the Request Animation Frame and setTimeout, which + * control the main game loop, will automatically pause. There is no way to stop this from happening. It is something + * your game should account for in its own code, should the pause be an issue (i.e. for multiplayer games) + */ + const HIDDEN: any; + + /** + * The Game Pause Event. + * + * This event is dispatched when the Game loop enters a paused state, usually as a result of the Visibility Handler. + */ + const PAUSE: any; + + /** + * The Game Post-Render Event. + * + * This event is dispatched right at the end of the render process. + * + * Every Scene will have rendered and been drawn to the canvas by the time this event is fired. + * Use it for any last minute post-processing before the next game step begins. + */ + const POST_RENDER: any; + + /** + * The Game Post-Step Event. + * + * This event is dispatched after the Scene Manager has updated. + * Hook into it from plugins or systems that need to do things before the render starts. + */ + const POST_STEP: any; + + /** + * The Game Pre-Render Event. + * + * This event is dispatched immediately before any of the Scenes have started to render. + * + * The renderer will already have been initialized this frame, clearing itself and preparing to receive the Scenes for rendering, but it won't have actually drawn anything yet. + */ + const PRE_RENDER: any; + + /** + * The Game Pre-Step Event. + * + * This event is dispatched before the main Game Step starts. By this point in the game cycle none of the Scene updates have yet happened. + * Hook into it from plugins or systems that need to update before the Scene Manager does. + */ + const PRE_STEP: any; + + /** + * The Game Ready Event. + * + * This event is dispatched when the Phaser Game instance has finished booting, the Texture Manager is fully ready, + * and all local systems are now able to start. + */ + const READY: any; + + /** + * The Game Resume Event. + * + * This event is dispatched when the game loop leaves a paused state and resumes running. + */ + const RESUME: any; + + /** + * The Game Step Event. + * + * This event is dispatched after the Game Pre-Step and before the Scene Manager steps. + * Hook into it from plugins or systems that need to update before the Scene Manager does, but after the core Systems have. + */ + const STEP: any; + + /** + * The Game Visible Event. + * + * This event is dispatched by the Game Visibility Handler when the document in which the Game instance is embedded + * enters a visible state, previously having been hidden. + * + * Only browsers that support the Visibility API will cause this event to be emitted. + */ + const VISIBLE: any; + + } + } namespace Create { @@ -6832,6 +6832,135 @@ declare namespace Phaser { } + /** + * A quadratic Bézier curve constructed from two control points. + */ + class QuadraticBezier extends Phaser.Curves.Curve { + /** + * + * @param p0 Start point, or an array of point pairs. + * @param p1 Control Point 1. + * @param p2 Control Point 2. + */ + constructor(p0: Phaser.Math.Vector2 | number[], p1: Phaser.Math.Vector2, p2: Phaser.Math.Vector2); + + /** + * The start point. + */ + p0: Phaser.Math.Vector2; + + /** + * The first control point. + */ + p1: Phaser.Math.Vector2; + + /** + * The second control point. + */ + p2: Phaser.Math.Vector2; + + /** + * Gets the starting point on the curve. + * @param out A Vector2 object to store the result in. If not given will be created. + */ + getStartPoint(out?: O): O; + + /** + * Get the resolution of the curve. + * @param divisions Optional divisions value. + */ + getResolution(divisions: number): number; + + /** + * Get point at relative position in curve according to length. + * @param t The position along the curve to return. Where 0 is the start and 1 is the end. + * @param out A Vector2 object to store the result in. If not given will be created. + */ + getPoint(t: number, out?: O): O; + + /** + * Draws this curve on the given Graphics object. + * + * The curve is drawn using `Graphics.strokePoints` so will be drawn at whatever the present Graphics stroke color is. + * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it. + * @param graphics `Graphics` object to draw onto. + * @param pointsTotal Number of points to be used for drawing the curve. Higher numbers result in smoother curve but require more processing. Default 32. + */ + draw(graphics: G, pointsTotal?: number): G; + + /** + * Converts the curve into a JSON compatible object. + */ + toJSON(): Phaser.Types.Curves.JSONCurve; + + /** + * Creates a curve from a JSON object, e. g. created by `toJSON`. + * @param data The JSON object containing this curve data. + */ + static fromJSON(data: Phaser.Types.Curves.JSONCurve): Phaser.Curves.QuadraticBezier; + + } + + /** + * Create a smooth 2d spline curve from a series of points. + */ + class Spline extends Phaser.Curves.Curve { + /** + * + * @param points The points that configure the curve. + */ + constructor(points?: Phaser.Math.Vector2[] | number[] | number[][]); + + /** + * The Vector2 points that configure the curve. + */ + points: Phaser.Math.Vector2[]; + + /** + * Add a list of points to the current list of Vector2 points of the curve. + * @param points The points that configure the curve. + */ + addPoints(points: Phaser.Math.Vector2[] | number[] | number[][]): this; + + /** + * Add a point to the current list of Vector2 points of the curve. + * @param x The x coordinate of this curve + * @param y The y coordinate of this curve + */ + addPoint(x: number, y: number): Phaser.Math.Vector2; + + /** + * Gets the starting point on the curve. + * @param out A Vector2 object to store the result in. If not given will be created. + */ + getStartPoint(out?: O): O; + + /** + * Get the resolution of the curve. + * @param divisions Optional divisions value. + */ + getResolution(divisions: number): number; + + /** + * Get point at relative position in curve according to length. + * @param t The position along the curve to return. Where 0 is the start and 1 is the end. + * @param out A Vector2 object to store the result in. If not given will be created. + */ + getPoint(t: number, out?: O): O; + + /** + * Exports a JSON object containing this curve data. + */ + toJSON(): Phaser.Types.Curves.JSONCurve; + + /** + * Imports a JSON object containing this curve data. + * @param data The JSON object containing this curve data. + */ + static fromJSON(data: Phaser.Types.Curves.JSONCurve): Phaser.Curves.Spline; + + } + /** * A MoveTo Curve is a very simple curve consisting of only a single point. * Its intended use is to move the ending point in a Path. @@ -7111,135 +7240,6 @@ declare namespace Phaser { } - /** - * A quadratic Bézier curve constructed from two control points. - */ - class QuadraticBezier extends Phaser.Curves.Curve { - /** - * - * @param p0 Start point, or an array of point pairs. - * @param p1 Control Point 1. - * @param p2 Control Point 2. - */ - constructor(p0: Phaser.Math.Vector2 | number[], p1: Phaser.Math.Vector2, p2: Phaser.Math.Vector2); - - /** - * The start point. - */ - p0: Phaser.Math.Vector2; - - /** - * The first control point. - */ - p1: Phaser.Math.Vector2; - - /** - * The second control point. - */ - p2: Phaser.Math.Vector2; - - /** - * Gets the starting point on the curve. - * @param out A Vector2 object to store the result in. If not given will be created. - */ - getStartPoint(out?: O): O; - - /** - * Get the resolution of the curve. - * @param divisions Optional divisions value. - */ - getResolution(divisions: number): number; - - /** - * Get point at relative position in curve according to length. - * @param t The position along the curve to return. Where 0 is the start and 1 is the end. - * @param out A Vector2 object to store the result in. If not given will be created. - */ - getPoint(t: number, out?: O): O; - - /** - * Draws this curve on the given Graphics object. - * - * The curve is drawn using `Graphics.strokePoints` so will be drawn at whatever the present Graphics stroke color is. - * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it. - * @param graphics `Graphics` object to draw onto. - * @param pointsTotal Number of points to be used for drawing the curve. Higher numbers result in smoother curve but require more processing. Default 32. - */ - draw(graphics: G, pointsTotal?: number): G; - - /** - * Converts the curve into a JSON compatible object. - */ - toJSON(): Phaser.Types.Curves.JSONCurve; - - /** - * Creates a curve from a JSON object, e. g. created by `toJSON`. - * @param data The JSON object containing this curve data. - */ - static fromJSON(data: Phaser.Types.Curves.JSONCurve): Phaser.Curves.QuadraticBezier; - - } - - /** - * Create a smooth 2d spline curve from a series of points. - */ - class Spline extends Phaser.Curves.Curve { - /** - * - * @param points The points that configure the curve. - */ - constructor(points?: Phaser.Math.Vector2[] | number[] | number[][]); - - /** - * The Vector2 points that configure the curve. - */ - points: Phaser.Math.Vector2[]; - - /** - * Add a list of points to the current list of Vector2 points of the curve. - * @param points The points that configure the curve. - */ - addPoints(points: Phaser.Math.Vector2[] | number[] | number[][]): this; - - /** - * Add a point to the current list of Vector2 points of the curve. - * @param x The x coordinate of this curve - * @param y The y coordinate of this curve - */ - addPoint(x: number, y: number): Phaser.Math.Vector2; - - /** - * Gets the starting point on the curve. - * @param out A Vector2 object to store the result in. If not given will be created. - */ - getStartPoint(out?: O): O; - - /** - * Get the resolution of the curve. - * @param divisions Optional divisions value. - */ - getResolution(divisions: number): number; - - /** - * Get point at relative position in curve according to length. - * @param t The position along the curve to return. Where 0 is the start and 1 is the end. - * @param out A Vector2 object to store the result in. If not given will be created. - */ - getPoint(t: number, out?: O): O; - - /** - * Exports a JSON object containing this curve data. - */ - toJSON(): Phaser.Types.Curves.JSONCurve; - - /** - * Imports a JSON object containing this curve data. - * @param data The JSON object containing this curve data. - */ - static fromJSON(data: Phaser.Types.Curves.JSONCurve): Phaser.Curves.Spline; - - } - } namespace Data { @@ -7947,6 +7947,241 @@ declare namespace Phaser { }; namespace Display { + /** + * The ColorMatrix class creates a 5x4 matrix that can be used in shaders and graphics + * operations. It provides methods required to modify the color values, such as adjusting + * the brightness, setting a sepia tone, hue rotation and more. + * + * Use the method `getData` to return a Float32Array containing the current color values. + */ + class ColorMatrix { + /** + * The value that determines how much of the original color is used + * when mixing the colors. A value between 0 (all original) and 1 (all final) + */ + alpha: number; + + /** + * Sets this ColorMatrix from the given array of color values. + * @param value The ColorMatrix values to set. + */ + set(value: number[]): this; + + /** + * Resets the ColorMatrix. + */ + reset(): this; + + /** + * Gets the ColorMatrix as a Float32Array. + * + * Can be used directly as a 1fv shader uniform value. + */ + getData(): Float32Array; + + /** + * Changes the brightness of this ColorMatrix by the given amount. + * @param value The amount of brightness to apply to this ColorMatrix. Between 0 (black) and 1. Default 0. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + brightness(value?: number, multiply?: boolean): this; + + /** + * Changes the saturation of this ColorMatrix by the given amount. + * @param value The amount of saturation to apply to this ColorMatrix. Default 0. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + saturate(value?: number, multiply?: boolean): this; + + /** + * Desaturates this ColorMatrix (removes color from it). + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + saturation(multiply?: boolean): this; + + /** + * Rotates the hues of this ColorMatrix by the value given. + * @param rotation The amount of hue rotation to apply to this ColorMatrix, in degrees. Default 0. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + hue(rotation?: number, multiply?: boolean): this; + + /** + * Sets this ColorMatrix to be grayscale. + * @param value The grayscale scale (0 is black). Default 1. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + grayscale(value?: number, multiply?: boolean): this; + + /** + * Sets this ColorMatrix to be black and white. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + blackWhite(multiply?: boolean): this; + + /** + * Change the contrast of this ColorMatrix by the amount given. + * @param value The amount of contrast to apply to this ColorMatrix. Default 0. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + contrast(value?: number, multiply?: boolean): this; + + /** + * Converts this ColorMatrix to have negative values. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + negative(multiply?: boolean): this; + + /** + * Apply a desaturated luminance to this ColorMatrix. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + desaturateLuminance(multiply?: boolean): this; + + /** + * Applies a sepia tone to this ColorMatrix. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + sepia(multiply?: boolean): this; + + /** + * Applies a night vision tone to this ColorMatrix. + * @param intensity The intensity of this effect. Default 0.1. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + night(intensity?: number, multiply?: boolean): this; + + /** + * Applies a trippy color tone to this ColorMatrix. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + lsd(multiply?: boolean): this; + + /** + * Applies a brown tone to this ColorMatrix. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + brown(multiply?: boolean): this; + + /** + * Applies a vintage pinhole color effect to this ColorMatrix. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + vintagePinhole(multiply?: boolean): this; + + /** + * Applies a kodachrome color effect to this ColorMatrix. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + kodachrome(multiply?: boolean): this; + + /** + * Applies a technicolor color effect to this ColorMatrix. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + technicolor(multiply?: boolean): this; + + /** + * Applies a polaroid color effect to this ColorMatrix. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + polaroid(multiply?: boolean): this; + + /** + * Shifts the values of this ColorMatrix into BGR order. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + shiftToBGR(multiply?: boolean): this; + + /** + * Multiplies the two given matrices. + * @param a The 5x4 array to multiply with ColorMatrix._matrix. + */ + multiply(a: number[]): this; + + } + + /** + * The RGB class holds a single color value and allows for easy modification and reading of it, + * with optional on-change callback notification and a dirty flag. + */ + class RGB { + /** + * + * @param red The red color value. A number between 0 and 1. Default 0. + * @param green The green color value. A number between 0 and 1. Default 0. + * @param blue The blue color value. A number between 0 and 1. Default 0. + */ + constructor(red?: number, green?: number, blue?: number); + + /** + * This callback will be invoked each time one of the RGB color values change. + * + * The callback is sent the new color values as the parameters. + */ + onChangeCallback: Function; + + /** + * Is this color dirty? + */ + dirty: boolean; + + /** + * Sets the red, green and blue values of this RGB object, flags it as being + * dirty and then invokes the `onChangeCallback`, if set. + * @param red The red color value. A number between 0 and 1. Default 0. + * @param green The green color value. A number between 0 and 1. Default 0. + * @param blue The blue color value. A number between 0 and 1. Default 0. + */ + set(red?: number, green?: number, blue?: number): this; + + /** + * Compares the given rgb parameters with those in this object and returns + * a boolean `true` value if they are equal, otherwise it returns `false`. + * @param red The red value to compare with this object. + * @param green The green value to compare with this object. + * @param blue The blue value to compare with this object. + */ + equals(red: number, green: number, blue: number): boolean; + + /** + * Internal on change handler. Sets this object as being dirty and + * then invokes the `onChangeCallback`, if set, passing in the + * new RGB values. + */ + onChange(): void; + + /** + * The red color value. Between 0 and 1. + * + * Changing this property will flag this RGB object as being dirty + * and invoke the `onChangeCallback` , if set. + */ + r: number; + + /** + * The green color value. Between 0 and 1. + * + * Changing this property will flag this RGB object as being dirty + * and invoke the `onChangeCallback` , if set. + */ + g: number; + + /** + * The blue color value. Between 0 and 1. + * + * Changing this property will flag this RGB object as being dirty + * and invoke the `onChangeCallback` , if set. + */ + b: number; + + /** + * Nulls any external references this object contains. + */ + destroy(): void; + + } + namespace Align { /** * A constant representing a top-left alignment or position. @@ -8748,16 +8983,6 @@ declare namespace Phaser { */ static GetColor32(red: number, green: number, blue: number, alpha: number): number; - /** - * Converts a hex string into a Phaser Color object. - * - * The hex string can supplied as `'#0033ff'` or the short-hand format of `'#03f'`; it can begin with an optional "#" or "0x", or be unprefixed. - * - * An alpha channel is _not_ supported. - * @param hex The hex color value to convert, such as `#0033ff` or the short-hand format: `#03f`. - */ - static HexStringToColor(hex: string): Phaser.Display.Color; - /** * Converts HSL (hue, saturation and lightness) values to a Phaser Color object. * @param h The hue value in the range 0 to 1. @@ -8786,6 +9011,16 @@ declare namespace Phaser { */ static HSVToRGB(h: number, s: number, v: number, out?: Phaser.Types.Display.ColorObject | Phaser.Display.Color): Phaser.Types.Display.ColorObject | Phaser.Display.Color; + /** + * Converts a hex string into a Phaser Color object. + * + * The hex string can supplied as `'#0033ff'` or the short-hand format of `'#03f'`; it can begin with an optional "#" or "0x", or be unprefixed. + * + * An alpha channel is _not_ supported. + * @param hex The hex color value to convert, such as `#0033ff` or the short-hand format: `#03f`. + */ + static HexStringToColor(hex: string): Phaser.Display.Color; + /** * Converts a hue to an RGB color. * Based on code by Michael Jackson (https://github.com/mjijackson) @@ -8812,14 +9047,6 @@ declare namespace Phaser { */ static ObjectToColor(input: Phaser.Types.Display.InputColorObject): Phaser.Display.Color; - /** - * Creates a new Color object where the r, g, and b values have been set to random values - * based on the given min max values. - * @param min The minimum value to set the random range from (between 0 and 255) Default 0. - * @param max The maximum value to set the random range from (between 0 and 255) Default 255. - */ - static RandomRGB(min?: number, max?: number): Phaser.Display.Color; - /** * Converts a CSS 'web' string into a Phaser Color object. * @@ -8850,6 +9077,14 @@ declare namespace Phaser { */ static RGBToString(r: number, g: number, b: number, a?: number, prefix?: string): string; + /** + * Creates a new Color object where the r, g, and b values have been set to random values + * based on the given min max values. + * @param min The minimum value to set the random range from (between 0 and 255) Default 0. + * @param max The maximum value to set the random range from (between 0 and 255) Default 255. + */ + static RandomRGB(min?: number, max?: number): Phaser.Display.Color; + /** * Converts the given source color value into an instance of a Color class. * The value can be either a string, prefixed with `rgb` or a hex string, a number or an Object. @@ -8859,160 +9094,6 @@ declare namespace Phaser { } - /** - * The ColorMatrix class creates a 5x4 matrix that can be used in shaders and graphics - * operations. It provides methods required to modify the color values, such as adjusting - * the brightness, setting a sepia tone, hue rotation and more. - * - * Use the method `getData` to return a Float32Array containing the current color values. - */ - class ColorMatrix { - /** - * The value that determines how much of the original color is used - * when mixing the colors. A value between 0 (all original) and 1 (all final) - */ - alpha: number; - - /** - * Sets this ColorMatrix from the given array of color values. - * @param value The ColorMatrix values to set. - */ - set(value: number[]): this; - - /** - * Resets the ColorMatrix. - */ - reset(): this; - - /** - * Gets the ColorMatrix as a Float32Array. - * - * Can be used directly as a 1fv shader uniform value. - */ - getData(): Float32Array; - - /** - * Changes the brightness of this ColorMatrix by the given amount. - * @param value The amount of brightness to apply to this ColorMatrix. Between 0 (black) and 1. Default 0. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - brightness(value?: number, multiply?: boolean): this; - - /** - * Changes the saturation of this ColorMatrix by the given amount. - * @param value The amount of saturation to apply to this ColorMatrix. Default 0. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - saturate(value?: number, multiply?: boolean): this; - - /** - * Desaturates this ColorMatrix (removes color from it). - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - saturation(multiply?: boolean): this; - - /** - * Rotates the hues of this ColorMatrix by the value given. - * @param rotation The amount of hue rotation to apply to this ColorMatrix, in degrees. Default 0. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - hue(rotation?: number, multiply?: boolean): this; - - /** - * Sets this ColorMatrix to be grayscale. - * @param value The grayscale scale (0 is black). Default 1. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - grayscale(value?: number, multiply?: boolean): this; - - /** - * Sets this ColorMatrix to be black and white. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - blackWhite(multiply?: boolean): this; - - /** - * Change the contrast of this ColorMatrix by the amount given. - * @param value The amount of contrast to apply to this ColorMatrix. Default 0. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - contrast(value?: number, multiply?: boolean): this; - - /** - * Converts this ColorMatrix to have negative values. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - negative(multiply?: boolean): this; - - /** - * Apply a desaturated luminance to this ColorMatrix. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - desaturateLuminance(multiply?: boolean): this; - - /** - * Applies a sepia tone to this ColorMatrix. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - sepia(multiply?: boolean): this; - - /** - * Applies a night vision tone to this ColorMatrix. - * @param intensity The intensity of this effect. Default 0.1. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - night(intensity?: number, multiply?: boolean): this; - - /** - * Applies a trippy color tone to this ColorMatrix. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - lsd(multiply?: boolean): this; - - /** - * Applies a brown tone to this ColorMatrix. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - brown(multiply?: boolean): this; - - /** - * Applies a vintage pinhole color effect to this ColorMatrix. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - vintagePinhole(multiply?: boolean): this; - - /** - * Applies a kodachrome color effect to this ColorMatrix. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - kodachrome(multiply?: boolean): this; - - /** - * Applies a technicolor color effect to this ColorMatrix. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - technicolor(multiply?: boolean): this; - - /** - * Applies a polaroid color effect to this ColorMatrix. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - polaroid(multiply?: boolean): this; - - /** - * Shifts the values of this ColorMatrix into BGR order. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - shiftToBGR(multiply?: boolean): this; - - /** - * Multiplies the two given matrices. - * @param a The 5x4 array to multiply with ColorMatrix._matrix. - */ - multiply(a: number[]): this; - - } - namespace Masks { /** * A Bitmap Mask combines the alpha (opacity) of a masked pixel with the alpha of another pixel. @@ -9269,87 +9350,6 @@ declare namespace Phaser { } - /** - * The RGB class holds a single color value and allows for easy modification and reading of it, - * with optional on-change callback notification and a dirty flag. - */ - class RGB { - /** - * - * @param red The red color value. A number between 0 and 1. Default 0. - * @param green The green color value. A number between 0 and 1. Default 0. - * @param blue The blue color value. A number between 0 and 1. Default 0. - */ - constructor(red?: number, green?: number, blue?: number); - - /** - * This callback will be invoked each time one of the RGB color values change. - * - * The callback is sent the new color values as the parameters. - */ - onChangeCallback: Function; - - /** - * Is this color dirty? - */ - dirty: boolean; - - /** - * Sets the red, green and blue values of this RGB object, flags it as being - * dirty and then invokes the `onChangeCallback`, if set. - * @param red The red color value. A number between 0 and 1. Default 0. - * @param green The green color value. A number between 0 and 1. Default 0. - * @param blue The blue color value. A number between 0 and 1. Default 0. - */ - set(red?: number, green?: number, blue?: number): this; - - /** - * Compares the given rgb parameters with those in this object and returns - * a boolean `true` value if they are equal, otherwise it returns `false`. - * @param red The red value to compare with this object. - * @param green The green value to compare with this object. - * @param blue The blue value to compare with this object. - */ - equals(red: number, green: number, blue: number): boolean; - - /** - * Internal on change handler. Sets this object as being dirty and - * then invokes the `onChangeCallback`, if set, passing in the - * new RGB values. - */ - onChange(): void; - - /** - * The red color value. Between 0 and 1. - * - * Changing this property will flag this RGB object as being dirty - * and invoke the `onChangeCallback` , if set. - */ - r: number; - - /** - * The green color value. Between 0 and 1. - * - * Changing this property will flag this RGB object as being dirty - * and invoke the `onChangeCallback` , if set. - */ - g: number; - - /** - * The blue color value. Between 0 and 1. - * - * Changing this property will flag this RGB object as being dirty - * and invoke the `onChangeCallback` , if set. - */ - b: number; - - /** - * Nulls any external references this object contains. - */ - destroy(): void; - - } - /** * A BaseShader is a small resource class that contains the data required for a WebGL Shader to be created. * @@ -9619,6 +9619,1685 @@ declare namespace Phaser { } namespace GameObjects { + /** + * Builds a Game Object using the provided configuration object. + * @param scene A reference to the Scene. + * @param gameObject The initial GameObject. + * @param config The config to build the GameObject with. + */ + function BuildGameObject(scene: Phaser.Scene, gameObject: Phaser.GameObjects.GameObject, config: Phaser.Types.GameObjects.GameObjectConfig): Phaser.GameObjects.GameObject; + + /** + * Adds an Animation component to a Sprite and populates it based on the given config. + * @param sprite The sprite to add an Animation component to. + * @param config The animation config. + */ + function BuildGameObjectAnimation(sprite: Phaser.GameObjects.Sprite, config: object): Phaser.GameObjects.Sprite; + + /** + * The Display List plugin. + * + * Display Lists belong to a Scene and maintain the list of Game Objects to render every frame. + * + * Some of these Game Objects may also be part of the Scene's [Update List]{@link Phaser.GameObjects.UpdateList}, for updating. + */ + class DisplayList extends Phaser.Structs.List { + /** + * + * @param scene The Scene that this Display List belongs to. + */ + constructor(scene: Phaser.Scene); + + /** + * The flag the determines whether Game Objects should be sorted when `depthSort()` is called. + */ + sortChildrenFlag: boolean; + + /** + * The Scene that this Display List belongs to. + */ + scene: Phaser.Scene; + + /** + * The Scene's Systems. + */ + systems: Phaser.Scenes.Systems; + + /** + * The Scene's Event Emitter. + */ + events: Phaser.Events.EventEmitter; + + /** + * Force a sort of the display list on the next call to depthSort. + */ + queueDepthSort(): void; + + /** + * Immediately sorts the display list if the flag is set. + */ + depthSort(): void; + + /** + * Compare the depth of two Game Objects. + * @param childA The first Game Object. + * @param childB The second Game Object. + */ + sortByDepth(childA: Phaser.GameObjects.GameObject, childB: Phaser.GameObjects.GameObject): number; + + /** + * Returns an array which contains all objects currently on the Display List. + * This is a reference to the main list array, not a copy of it, so be careful not to modify it. + */ + getChildren(): Phaser.GameObjects.GameObject[]; + + } + + /** + * The base class that all Game Objects extend. + * You don't create GameObjects directly and they cannot be added to the display list. + * Instead, use them as the base for your own custom classes. + */ + class GameObject extends Phaser.Events.EventEmitter { + /** + * + * @param scene The Scene to which this Game Object belongs. + * @param type A textual representation of the type of Game Object, i.e. `sprite`. + */ + constructor(scene: Phaser.Scene, type: string); + + /** + * A reference to the Scene to which this Game Object belongs. + * + * Game Objects can only belong to one Scene. + * + * You should consider this property as being read-only. You cannot move a + * Game Object to another Scene by simply changing it. + */ + scene: Phaser.Scene; + + /** + * Holds a reference to the Display List that contains this Game Object. + * + * This is set automatically when this Game Object is added to a Scene or Layer. + * + * You should treat this property as being read-only. + */ + displayList: Phaser.GameObjects.DisplayList | Phaser.GameObjects.Layer; + + /** + * A textual representation of this Game Object, i.e. `sprite`. + * Used internally by Phaser but is available for your own custom classes to populate. + */ + type: string; + + /** + * The current state of this Game Object. + * + * Phaser itself will never modify this value, although plugins may do so. + * + * Use this property to track the state of a Game Object during its lifetime. For example, it could change from + * a state of 'moving', to 'attacking', to 'dead'. The state value should be an integer (ideally mapped to a constant + * in your game code), or a string. These are recommended to keep it light and simple, with fast comparisons. + * If you need to store complex data about your Game Object, look at using the Data Component instead. + */ + state: number | string; + + /** + * The parent Container of this Game Object, if it has one. + */ + parentContainer: Phaser.GameObjects.Container; + + /** + * The name of this Game Object. + * Empty by default and never populated by Phaser, this is left for developers to use. + */ + name: string; + + /** + * The active state of this Game Object. + * A Game Object with an active state of `true` is processed by the Scenes UpdateList, if added to it. + * An active object is one which is having its logic and internal systems updated. + */ + active: boolean; + + /** + * The Tab Index of the Game Object. + * Reserved for future use by plugins and the Input Manager. + */ + tabIndex: number; + + /** + * A Data Manager. + * It allows you to store, query and get key/value paired information specific to this Game Object. + * `null` by default. Automatically created if you use `getData` or `setData` or `setDataEnabled`. + */ + data: Phaser.Data.DataManager; + + /** + * The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not. + * The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively. + * If those components are not used by your custom class then you can use this bitmask as you wish. + */ + renderFlags: number; + + /** + * A bitmask that controls if this Game Object is drawn by a Camera or not. + * Not usually set directly, instead call `Camera.ignore`, however you can + * set this property directly using the Camera.id property: + */ + cameraFilter: number; + + /** + * If this Game Object is enabled for input then this property will contain an InteractiveObject instance. + * Not usually set directly. Instead call `GameObject.setInteractive()`. + */ + input: Phaser.Types.Input.InteractiveObject; + + /** + * If this Game Object is enabled for Arcade or Matter Physics then this property will contain a reference to a Physics Body. + */ + body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody | MatterJS.BodyType; + + /** + * This Game Object will ignore all calls made to its destroy method if this flag is set to `true`. + * This includes calls that may come from a Group, Container or the Scene itself. + * While it allows you to persist a Game Object across Scenes, please understand you are entirely + * responsible for managing references to and from this Game Object. + */ + ignoreDestroy: boolean; + + /** + * Sets the `active` property of this Game Object and returns this Game Object for further chaining. + * A Game Object with its `active` property set to `true` will be updated by the Scenes UpdateList. + * @param value True if this Game Object should be set as active, false if not. + */ + setActive(value: boolean): this; + + /** + * Sets the `name` property of this Game Object and returns this Game Object for further chaining. + * The `name` property is not populated by Phaser and is presented for your own use. + * @param value The name to be given to this Game Object. + */ + setName(value: string): this; + + /** + * Sets the current state of this Game Object. + * + * Phaser itself will never modify the State of a Game Object, although plugins may do so. + * + * For example, a Game Object could change from a state of 'moving', to 'attacking', to 'dead'. + * The state value should typically be an integer (ideally mapped to a constant + * in your game code), but could also be a string. It is recommended to keep it light and simple. + * If you need to store complex data about your Game Object, look at using the Data Component instead. + * @param value The state of the Game Object. + */ + setState(value: number | string): this; + + /** + * Adds a Data Manager component to this Game Object. + */ + setDataEnabled(): this; + + /** + * Allows you to store a key value pair within this Game Objects Data Manager. + * + * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled + * before setting the value. + * + * If the key doesn't already exist in the Data Manager then it is created. + * + * ```javascript + * sprite.setData('name', 'Red Gem Stone'); + * ``` + * + * You can also pass in an object of key value pairs as the first argument: + * + * ```javascript + * sprite.setData({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); + * ``` + * + * To get a value back again you can call `getData`: + * + * ```javascript + * sprite.getData('gold'); + * ``` + * + * Or you can access the value directly via the `values` property, where it works like any other variable: + * + * ```javascript + * sprite.data.values.gold += 50; + * ``` + * + * When the value is first set, a `setdata` event is emitted from this Game Object. + * + * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. + * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata-PlayerLives`. + * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. + * + * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * @param key The key to set the value for. Or an object of key value pairs. If an object the `data` argument is ignored. + * @param data The value to set for the given key. If an object is provided as the key this argument is ignored. + */ + setData(key: string | object, data?: any): this; + + /** + * Increase a value for the given key within this Game Objects Data Manager. If the key doesn't already exist in the Data Manager then it is increased from 0. + * + * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled + * before setting the value. + * + * If the key doesn't already exist in the Data Manager then it is created. + * + * When the value is first set, a `setdata` event is emitted from this Game Object. + * @param key The key to increase the value for. + * @param data The value to increase for the given key. + */ + incData(key: string | object, data?: any): this; + + /** + * Toggle a boolean value for the given key within this Game Objects Data Manager. If the key doesn't already exist in the Data Manager then it is toggled from false. + * + * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled + * before setting the value. + * + * If the key doesn't already exist in the Data Manager then it is created. + * + * When the value is first set, a `setdata` event is emitted from this Game Object. + * @param key The key to toggle the value for. + */ + toggleData(key: string | object): this; + + /** + * Retrieves the value for the given key in this Game Objects Data Manager, or undefined if it doesn't exist. + * + * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: + * + * ```javascript + * sprite.getData('gold'); + * ``` + * + * Or access the value directly: + * + * ```javascript + * sprite.data.values.gold; + * ``` + * + * You can also pass in an array of keys, in which case an array of values will be returned: + * + * ```javascript + * sprite.getData([ 'gold', 'armor', 'health' ]); + * ``` + * + * This approach is useful for destructuring arrays in ES6. + * @param key The key of the value to retrieve, or an array of keys. + */ + getData(key: string | string[]): any; + + /** + * Pass this Game Object to the Input Manager to enable it for Input. + * + * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area + * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced + * input detection. + * + * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If + * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific + * shape for it to use. + * + * You can also provide an Input Configuration Object as the only argument to this method. + * @param hitArea Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not given it will try to create a Rectangle based on the texture frame. + * @param callback The callback that determines if the pointer is within the Hit Area shape or not. If you provide a shape you must also provide a callback. + * @param dropZone Should this Game Object be treated as a drop zone target? Default false. + */ + setInteractive(hitArea?: Phaser.Types.Input.InputConfiguration | any, callback?: Phaser.Types.Input.HitAreaCallback, dropZone?: boolean): this; + + /** + * If this Game Object has previously been enabled for input, this will disable it. + * + * An object that is disabled for input stops processing or being considered for + * input events, but can be turned back on again at any time by simply calling + * `setInteractive()` with no arguments provided. + * + * If want to completely remove interaction from this Game Object then use `removeInteractive` instead. + */ + disableInteractive(): this; + + /** + * If this Game Object has previously been enabled for input, this will queue it + * for removal, causing it to no longer be interactive. The removal happens on + * the next game step, it is not immediate. + * + * The Interactive Object that was assigned to this Game Object will be destroyed, + * removed from the Input Manager and cleared from this Game Object. + * + * If you wish to re-enable this Game Object at a later date you will need to + * re-create its InteractiveObject by calling `setInteractive` again. + * + * If you wish to only temporarily stop an object from receiving input then use + * `disableInteractive` instead, as that toggles the interactive state, where-as + * this erases it completely. + * + * If you wish to resize a hit area, don't remove and then set it as being + * interactive. Instead, access the hitarea object directly and resize the shape + * being used. I.e.: `sprite.input.hitArea.setSize(width, height)` (assuming the + * shape is a Rectangle, which it is by default.) + */ + removeInteractive(): this; + + /** + * This callback is invoked when this Game Object is added to a Scene. + * + * Can be overriden by custom Game Objects, but be aware of some Game Objects that + * will use this, such as Sprites, to add themselves into the Update List. + * + * You can also listen for the `ADDED_TO_SCENE` event from this Game Object. + */ + addedToScene(): void; + + /** + * This callback is invoked when this Game Object is removed from a Scene. + * + * Can be overriden by custom Game Objects, but be aware of some Game Objects that + * will use this, such as Sprites, to removed themselves from the Update List. + * + * You can also listen for the `REMOVED_FROM_SCENE` event from this Game Object. + */ + removedFromScene(): void; + + /** + * To be overridden by custom GameObjects. Allows base objects to be used in a Pool. + * @param args args + */ + update(...args: any[]): void; + + /** + * Returns a JSON representation of the Game Object. + */ + toJSON(): Phaser.Types.GameObjects.JSONGameObject; + + /** + * Compares the renderMask with the renderFlags to see if this Game Object will render or not. + * Also checks the Game Object against the given Cameras exclusion list. + * @param camera The Camera to check against this Game Object. + */ + willRender(camera: Phaser.Cameras.Scene2D.Camera): boolean; + + /** + * Returns an array containing the display list index of either this Game Object, or if it has one, + * its parent Container. It then iterates up through all of the parent containers until it hits the + * root of the display list (which is index 0 in the returned array). + * + * Used internally by the InputPlugin but also useful if you wish to find out the display depth of + * this Game Object and all of its ancestors. + */ + getIndexList(): number[]; + + /** + * Adds this Game Object to the given Display List. + * + * If no Display List is specified, it will default to the Display List owned by the Scene to which + * this Game Object belongs. + * + * A Game Object can only exist on one Display List at any given time, but may move freely between them. + * + * If this Game Object is already on another Display List when this method is called, it will first + * be removed from it, before being added to the new list. + * + * You can query which list it is on by looking at the `Phaser.GameObjects.GameObject#displayList` property. + * + * If a Game Object isn't on any display list, it will not be rendered. If you just wish to temporarly + * disable it from rendering, consider using the `setVisible` method, instead. + * @param displayList The Display List to add to. Defaults to the Scene Display List. + */ + addToDisplayList(displayList?: Phaser.GameObjects.DisplayList | Phaser.GameObjects.Layer): this; + + /** + * Adds this Game Object to the Update List belonging to the Scene. + * + * When a Game Object is added to the Update List it will have its `preUpdate` method called + * every game frame. This method is passed two parameters: `delta` and `time`. + * + * If you wish to run your own logic within `preUpdate` then you should always call + * `preUpdate.super(delta, time)` within it, or it may fail to process required operations, + * such as Sprite animations. + */ + addToUpdateList(): this; + + /** + * Removes this Game Object from the Display List it is currently on. + * + * A Game Object can only exist on one Display List at any given time, but may move freely removed + * and added back at a later stage. + * + * You can query which list it is on by looking at the `Phaser.GameObjects.GameObject#displayList` property. + * + * If a Game Object isn't on any Display List, it will not be rendered. If you just wish to temporarly + * disable it from rendering, consider using the `setVisible` method, instead. + */ + removeFromDisplayList(): this; + + /** + * Removes this Game Object from the Scene's Update List. + * + * When a Game Object is on the Update List, it will have its `preUpdate` method called + * every game frame. Calling this method will remove it from the list, preventing this. + * + * Removing a Game Object from the Update List will stop most internal functions working. + * For example, removing a Sprite from the Update List will prevent it from being able to + * run animations. + */ + removeFromUpdateList(): this; + + /** + * Destroys this Game Object removing it from the Display List and Update List and + * severing all ties to parent resources. + * + * Also removes itself from the Input Manager and Physics Manager if previously enabled. + * + * Use this to remove a Game Object from your game if you don't ever plan to use it again. + * As long as no reference to it exists within your own code it should become free for + * garbage collection by the browser. + * + * If you just want to temporarily disable an object then look at using the + * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. + */ + destroy(): void; + + /** + * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not. + */ + static readonly RENDER_MASK: number; + + } + + /** + * The Game Object Creator is a Scene plugin that allows you to quickly create many common + * types of Game Objects and return them. Unlike the Game Object Factory, they are not automatically + * added to the Scene. + * + * Game Objects directly register themselves with the Creator and inject their own creation + * methods into the class. + */ + class GameObjectCreator { + /** + * + * @param scene The Scene to which this Game Object Factory belongs. + */ + constructor(scene: Phaser.Scene); + + /** + * The Scene to which this Game Object Creator belongs. + */ + protected scene: Phaser.Scene; + + /** + * A reference to the Scene.Systems. + */ + protected systems: Phaser.Scenes.Systems; + + /** + * A reference to the Scene Event Emitter. + */ + protected events: Phaser.Events.EventEmitter; + + /** + * A reference to the Scene Display List. + */ + protected displayList: Phaser.GameObjects.DisplayList; + + /** + * A reference to the Scene Update List. + */ + protected updateList: Phaser.GameObjects.UpdateList; + + /** + * Creates a new Dynamic Bitmap Text Game Object and returns it. + * + * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + dynamicBitmapText(config: Phaser.Types.GameObjects.BitmapText.BitmapTextConfig, addToScene?: boolean): Phaser.GameObjects.DynamicBitmapText; + + /** + * Creates a new Bitmap Text Game Object and returns it. + * + * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + bitmapText(config: Phaser.Types.GameObjects.BitmapText.BitmapTextConfig, addToScene?: boolean): Phaser.GameObjects.BitmapText; + + /** + * Creates a new Blitter Game Object and returns it. + * + * Note: This method will only be available if the Blitter Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + blitter(config: object, addToScene?: boolean): Phaser.GameObjects.Blitter; + + /** + * Creates a new Container Game Object and returns it. + * + * Note: This method will only be available if the Container Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + container(config: object, addToScene?: boolean): Phaser.GameObjects.Container; + + /** + * Creates a new Graphics Game Object and returns it. + * + * Note: This method will only be available if the Graphics Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + graphics(config: object, addToScene?: boolean): Phaser.GameObjects.Graphics; + + /** + * Creates a new Group Game Object and returns it. + * + * Note: This method will only be available if the Group Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + */ + group(config: Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig): Phaser.GameObjects.Group; + + /** + * Creates a new Image Game Object and returns it. + * + * Note: This method will only be available if the Image Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + image(config: object, addToScene?: boolean): Phaser.GameObjects.Image; + + /** + * Creates a new Layer Game Object and returns it. + * + * Note: This method will only be available if the Layer Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + layer(config: object, addToScene?: boolean): Phaser.GameObjects.Layer; + + /** + * Creates a new Mesh Game Object and returns it. + * + * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + mesh(config: object, addToScene?: boolean): Phaser.GameObjects.Mesh; + + /** + * Creates a new Particle Emitter Manager Game Object and returns it. + * + * Note: This method will only be available if the Particles Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + particles(config: object, addToScene?: boolean): Phaser.GameObjects.Particles.ParticleEmitterManager; + + /** + * Creates a new Point Light Game Object and returns it. + * + * Note: This method will only be available if the Point Light Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + pointlight(config: object, addToScene?: boolean): Phaser.GameObjects.PointLight; + + /** + * Creates a new Render Texture Game Object and returns it. + * + * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + renderTexture(config: Phaser.Types.GameObjects.RenderTexture.RenderTextureConfig, addToScene?: boolean): Phaser.GameObjects.RenderTexture; + + /** + * Creates a new Rope Game Object and returns it. + * + * Note: This method will only be available if the Rope Game Object and WebGL support have been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + rope(config: object, addToScene?: boolean): Phaser.GameObjects.Rope; + + /** + * Creates a new Shader Game Object and returns it. + * + * Note: This method will only be available if the Shader Game Object and WebGL support have been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + shader(config: object, addToScene?: boolean): Phaser.GameObjects.Shader; + + /** + * Creates a new Sprite Game Object and returns it. + * + * Note: This method will only be available if the Sprite Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + sprite(config: Phaser.Types.GameObjects.Sprite.SpriteConfig, addToScene?: boolean): Phaser.GameObjects.Sprite; + + /** + * Creates a new Text Game Object and returns it. + * + * Note: This method will only be available if the Text Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + text(config: Phaser.Types.GameObjects.Text.TextConfig, addToScene?: boolean): Phaser.GameObjects.Text; + + /** + * Creates a new TileSprite Game Object and returns it. + * + * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + tileSprite(config: Phaser.Types.GameObjects.TileSprite.TileSpriteConfig, addToScene?: boolean): Phaser.GameObjects.TileSprite; + + /** + * Creates a new Video Game Object and returns it. + * + * Note: This method will only be available if the Video Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + video(config: object, addToScene?: boolean): Phaser.GameObjects.Video; + + /** + * Creates a new Zone Game Object and returns it. + * + * Note: This method will only be available if the Zone Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + */ + zone(config: object): Phaser.GameObjects.Zone; + + /** + * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. + * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing + * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map + * data. For an empty map, you should specify tileWidth, tileHeight, width & height. + * @param config The config options for the Tilemap. + */ + tilemap(config?: Phaser.Types.Tilemaps.TilemapConfig): Phaser.Tilemaps.Tilemap; + + /** + * Creates a new Tween object and returns it. + * + * Note: This method will only be available if Tweens have been built into Phaser. + * @param config The Tween configuration. + */ + tween(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.Tween; + + } + + /** + * The Game Object Factory is a Scene plugin that allows you to quickly create many common + * types of Game Objects and have them automatically registered with the Scene. + * + * Game Objects directly register themselves with the Factory and inject their own creation + * methods into the class. + */ + class GameObjectFactory { + /** + * + * @param scene The Scene to which this Game Object Factory belongs. + */ + constructor(scene: Phaser.Scene); + + /** + * Creates a new Path Object. + * @param x The horizontal position of this Path. + * @param y The vertical position of this Path. + */ + path(x: number, y: number): Phaser.Curves.Path; + + /** + * The Scene to which this Game Object Factory belongs. + */ + protected scene: Phaser.Scene; + + /** + * A reference to the Scene.Systems. + */ + protected systems: Phaser.Scenes.Systems; + + /** + * A reference to the Scene Event Emitter. + */ + protected events: Phaser.Events.EventEmitter; + + /** + * A reference to the Scene Display List. + */ + protected displayList: Phaser.GameObjects.DisplayList; + + /** + * A reference to the Scene Update List. + */ + protected updateList: Phaser.GameObjects.UpdateList; + + /** + * Adds an existing Game Object to this Scene. + * + * If the Game Object renders, it will be added to the Display List. + * If it has a `preUpdate` method, it will be added to the Update List. + * @param child The child to be added to this Scene. + */ + existing(child: G): G; + + /** + * Static method called directly by the Game Object factory functions. + * With this method you can register a custom GameObject factory in the GameObjectFactory, + * providing a name (`factoryType`) and the constructor (`factoryFunction`) in order + * to be called when you call to Phaser.Scene.add[ factoryType ] method. + * @param factoryType The key of the factory that you will use to call to Phaser.Scene.add[ factoryType ] method. + * @param factoryFunction The constructor function to be called when you invoke to the Phaser.Scene.add method. + */ + static register(factoryType: string, factoryFunction: Function): void; + + /** + * Static method called directly by the Game Object factory functions. + * With this method you can remove a custom GameObject factory registered in the GameObjectFactory, + * providing a its `factoryType`. + * @param factoryType The key of the factory that you want to remove from the GameObjectFactory. + */ + static remove(factoryType: string): void; + + /** + * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. + * + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each + * letter being rendered during the render pass. This callback allows you to manipulate the properties of + * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects + * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing + * time, so only use them if you require the callback ability they have. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. + * @param x The x position of the Game Object. + * @param y The y position of the Game Object. + * @param font The key of the font to use from the BitmapFont cache. + * @param text The string, or array of strings, to be set as the content of this Bitmap Text. + * @param size The font size to set. + */ + dynamicBitmapText(x: number, y: number, font: string, text?: string | string[], size?: number): Phaser.GameObjects.DynamicBitmapText; + + /** + * Creates a new Bitmap Text Game Object and adds it to the Scene. + * + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. + * @param x The x position of the Game Object. + * @param y The y position of the Game Object. + * @param font The key of the font to use from the BitmapFont cache. + * @param text The string, or array of strings, to be set as the content of this Bitmap Text. + * @param size The font size to set. + * @param align The alignment of the text in a multi-line BitmapText object. Default 0. + */ + bitmapText(x: number, y: number, font: string, text?: string | string[], size?: number, align?: number): Phaser.GameObjects.BitmapText; + + /** + * Creates a new Blitter Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Blitter Game Object has been built into Phaser. + * @param x The x position of the Game Object. + * @param y The y position of the Game Object. + * @param key The key of the Texture the Blitter object will use. + * @param frame The default Frame children of the Blitter will use. + */ + blitter(x: number, y: number, key: string, frame?: string | number): Phaser.GameObjects.Blitter; + + /** + * Creates a new Container Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Container Game Object has been built into Phaser. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param children An optional array of Game Objects to add to this Container. + */ + container(x?: number, y?: number, children?: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[]): Phaser.GameObjects.Container; + + /** + * DOM Element Game Objects are a way to control and manipulate HTML Elements over the top of your game. + * + * In order for DOM Elements to display you have to enable them by adding the following to your game + * configuration object: + * + * ```javascript + * dom { + * createContainer: true + * } + * ``` + * + * When this is added, Phaser will automatically create a DOM Container div that is positioned over the top + * of the game canvas. This div is sized to match the canvas, and if the canvas size changes, as a result of + * settings within the Scale Manager, the dom container is resized accordingly. + * + * You can create a DOM Element by either passing in DOMStrings, or by passing in a reference to an existing + * Element that you wish to be placed under the control of Phaser. For example: + * + * ```javascript + * this.add.dom(x, y, 'div', 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser'); + * ``` + * + * The above code will insert a div element into the DOM Container at the given x/y coordinate. The DOMString in + * the 4th argument sets the initial CSS style of the div and the final argument is the inner text. In this case, + * it will create a lime colored div that is 220px by 100px in size with the text Phaser in it, in an Arial font. + * + * You should nearly always, without exception, use explicitly sized HTML Elements, in order to fully control + * alignment and positioning of the elements next to regular game content. + * + * Rather than specify the CSS and HTML directly you can use the `load.html` File Loader to load it into the + * cache and then use the `createFromCache` method instead. You can also use `createFromHTML` and various other + * methods available in this class to help construct your elements. + * + * Once the element has been created you can then control it like you would any other Game Object. You can set its + * position, scale, rotation, alpha and other properties. It will move as the main Scene Camera moves and be clipped + * at the edge of the canvas. It's important to remember some limitations of DOM Elements: The obvious one is that + * they appear above or below your game canvas. You cannot blend them into the display list, meaning you cannot have + * a DOM Element, then a Sprite, then another DOM Element behind it. + * + * They also cannot be enabled for input. To do that, you have to use the `addListener` method to add native event + * listeners directly. The final limitation is to do with cameras. The DOM Container is sized to match the game canvas + * entirely and clipped accordingly. DOM Elements respect camera scrolling and scrollFactor settings, but if you + * change the size of the camera so it no longer matches the size of the canvas, they won't be clipped accordingly. + * + * Also, all DOM Elements are inserted into the same DOM Container, regardless of which Scene they are created in. + * + * DOM Elements are a powerful way to align native HTML with your Phaser Game Objects. For example, you can insert + * a login form for a multiplayer game directly into your title screen. Or a text input box for a highscore table. + * Or a banner ad from a 3rd party service. Or perhaps you'd like to use them for high resolution text display and + * UI. The choice is up to you, just remember that you're dealing with standard HTML and CSS floating over the top + * of your game, and should treat it accordingly. + * + * Note: This method will only be available if the DOM Element Game Object has been built into Phaser. + * @param x The horizontal position of this DOM Element in the world. + * @param y The vertical position of this DOM Element in the world. + * @param element An existing DOM element, or a string. If a string starting with a # it will do a `getElementById` look-up on the string (minus the hash). Without a hash, it represents the type of element to create, i.e. 'div'. + * @param style If a string, will be set directly as the elements `style` property value. If a plain object, will be iterated and the values transferred. In both cases the values replacing whatever CSS styles may have been previously set. + * @param innerText If given, will be set directly as the elements `innerText` property value, replacing whatever was there before. + */ + dom(x: number, y: number, element?: HTMLElement | string, style?: string | any, innerText?: string): Phaser.GameObjects.DOMElement; + + /** + * Creates a new Extern Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Extern Game Object has been built into Phaser. + */ + extern(): Phaser.GameObjects.Extern; + + /** + * Creates a new Graphics Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Graphics Game Object has been built into Phaser. + * @param config The Graphics configuration. + */ + graphics(config?: Phaser.Types.GameObjects.Graphics.Options): Phaser.GameObjects.Graphics; + + /** + * Creates a new Group Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Group Game Object has been built into Phaser. + * @param children Game Objects to add to this Group; or the `config` argument. + * @param config A Group Configuration object. + */ + group(children?: Phaser.GameObjects.GameObject[] | Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupConfig[], config?: Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig): Phaser.GameObjects.Group; + + /** + * Creates a new Image Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Image Game Object has been built into Phaser. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Game Object is rendering with. + */ + image(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.Image; + + /** + * Creates a new Layer Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Layer Game Object has been built into Phaser. + * @param children An optional array of Game Objects to add to this Layer. + */ + layer(children?: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[]): Phaser.GameObjects.Layer; + + /** + * Creates a new Mesh Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Game Object is rendering with. + * @param vertices The vertices array. Either `xy` pairs, or `xyz` if the `containsZ` parameter is `true`. + * @param uvs The UVs pairs array. + * @param indicies Optional vertex indicies array. If you don't have one, pass `null` or an empty array. + * @param containsZ Does the vertices data include a `z` component? Default false. + * @param normals Optional vertex normals array. If you don't have one, pass `null` or an empty array. + * @param colors An array of colors, one per vertex, or a single color value applied to all vertices. Default 0xffffff. + * @param alphas An array of alpha values, one per vertex, or a single alpha value applied to all vertices. Default 1. + */ + mesh(x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number, vertices?: number[], uvs?: number[], indicies?: number[], containsZ?: boolean, normals?: number[], colors?: number | number[], alphas?: number | number[]): Phaser.GameObjects.Mesh; + + /** + * Creates a new Particle Emitter Manager Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Particles Game Object has been built into Phaser. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Game Object is rendering with. + * @param emitters Configuration settings for one or more emitters to create. + */ + particles(texture: string | Phaser.Textures.Texture, frame?: string | number | object, emitters?: Phaser.Types.GameObjects.Particles.ParticleEmitterConfig | Phaser.Types.GameObjects.Particles.ParticleEmitterConfig[]): Phaser.GameObjects.Particles.ParticleEmitterManager; + + /** + * Creates a new PathFollower Game Object and adds it to the Scene. + * + * Note: This method will only be available if the PathFollower Game Object has been built into Phaser. + * @param path The Path this PathFollower is connected to. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Game Object is rendering with. + */ + follower(path: Phaser.Curves.Path, x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.PathFollower; + + /** + * Creates a new Point Light Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Point Light Game Object has been built into Phaser. + * + * The Point Light Game Object provides a way to add a point light effect into your game, + * without the expensive shader processing requirements of the traditional Light Game Object. + * + * The difference is that the Point Light renders using a custom shader, designed to give the + * impression of a point light source, of variable radius, intensity and color, in your game. + * However, unlike the Light Game Object, it does not impact any other Game Objects, or use their + * normal maps for calcuations. This makes them extremely fast to render compared to Lights + * and perfect for special effects, such as flickering torches or muzzle flashes. + * + * For maximum performance you should batch Point Light Game Objects together. This means + * ensuring they follow each other consecutively on the display list. Ideally, use a Layer + * Game Object and then add just Point Lights to it, so that it can batch together the rendering + * of the lights. You don't _have_ to do this, and if you've only a handful of Point Lights in + * your game then it's perfectly safe to mix them into the dislay list as normal. However, if + * you're using a large number of them, please consider how they are mixed into the display list. + * + * The renderer will automatically cull Point Lights. Those with a radius that does not intersect + * with the Camera will be skipped in the rendering list. This happens automatically and the + * culled state is refreshed every frame, for every camera. + * + * The origin of a Point Light is always 0.5 and it cannot be changed. + * + * Point Lights are a WebGL only feature and do not have a Canvas counterpart. + * @param x The horizontal position of this Point Light in the world. + * @param y The vertical position of this Point Light in the world. + * @param color The color of the Point Light, given as a hex value. Default 0xffffff. + * @param radius The radius of the Point Light. Default 128. + * @param intensity The intensity, or colr blend, of the Point Light. Default 1. + * @param attenuation The attenuation of the Point Light. This is the reduction of light from the center point. Default 0.1. + */ + pointlight(x: number, y: number, color?: number, radius?: number, intensity?: number, attenuation?: number): Phaser.GameObjects.PointLight; + + /** + * Creates a new Render Texture Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. + * + * A Render Texture is a special texture that allows any number of Game Objects to be drawn to it. You can take many complex objects and + * draw them all to this one texture, which can they be used as the texture for other Game Object's. It's a way to generate dynamic + * textures at run-time that are WebGL friendly and don't invoke expensive GPU uploads. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param width The width of the Render Texture. Default 32. + * @param height The height of the Render Texture. Default 32. + */ + renderTexture(x: number, y: number, width?: number, height?: number): Phaser.GameObjects.RenderTexture; + + /** + * Creates a new Rope Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Rope Game Object and WebGL support have been built into Phaser. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Game Object is rendering with. + * @param points An array containing the vertices data for this Rope. If none is provided a simple quad is created. See `setPoints` to set this post-creation. + * @param horizontal Should the vertices of this Rope be aligned horizontally (`true`), or vertically (`false`)? Default true. + * @param colors An optional array containing the color data for this Rope. You should provide one color value per pair of vertices. + * @param alphas An optional array containing the alpha data for this Rope. You should provide one alpha value per pair of vertices. + */ + rope(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number, points?: Phaser.Types.Math.Vector2Like[], horizontal?: boolean, colors?: number[], alphas?: number[]): Phaser.GameObjects.Rope; + + /** + * Creates a new Shader Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Shader Game Object and WebGL support have been built into Phaser. + * @param key The key of the shader to use from the shader cache, or a BaseShader instance. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param width The width of the Game Object. Default 128. + * @param height The height of the Game Object. Default 128. + * @param textures Optional array of texture keys to bind to the iChannel0...3 uniforms. The textures must already exist in the Texture Manager. + * @param textureData Optional additional texture data. + */ + shader(key: string | Phaser.Display.BaseShader, x?: number, y?: number, width?: number, height?: number, textures?: string[], textureData?: object): Phaser.GameObjects.Shader; + + /** + * Creates a new Arc Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Arc Game Object has been built into Phaser. + * + * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an arc shape. You can control the start and end angles of the arc, + * as well as if the angles are winding clockwise or anti-clockwise. With the default settings + * it renders as a complete circle. By changing the angles you can create other arc shapes, + * such as half-circles. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param radius The radius of the arc. Default 128. + * @param startAngle The start angle of the arc, in degrees. Default 0. + * @param endAngle The end angle of the arc, in degrees. Default 360. + * @param anticlockwise The winding order of the start and end angles. Default false. + * @param fillColor The color the arc will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the arc will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + arc(x?: number, y?: number, radius?: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Arc; + + /** + * Creates a new Circle Shape Game Object and adds it to the Scene. + * + * A Circle is an Arc with no defined start and end angle, making it render as a complete circle. + * + * Note: This method will only be available if the Arc Game Object has been built into Phaser. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param radius The radius of the circle. Default 128. + * @param fillColor The color the circle will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the circle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + circle(x?: number, y?: number, radius?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Arc; + + /** + * Creates a new Curve Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Curve Game Object has been built into Phaser. + * + * The Curve Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * To render a Curve Shape you must first create a `Phaser.Curves.Curve` object, then pass it to + * the Curve Shape in the constructor. + * + * The Curve shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param curve The Curve object to use to create the Shape. + * @param fillColor The color the curve will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the curve will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + curve(x?: number, y?: number, curve?: Phaser.Curves.Curve, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Curve; + + /** + * Creates a new Ellipse Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Ellipse Game Object has been built into Phaser. + * + * The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an ellipse shape. You can control the width and height of the ellipse. + * If the width and height match it will render as a circle. If the width is less than the height, + * it will look more like an egg shape. + * + * The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param width The width of the ellipse. An ellipse with equal width and height renders as a circle. Default 128. + * @param height The height of the ellipse. An ellipse with equal width and height renders as a circle. Default 128. + * @param fillColor The color the ellipse will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + ellipse(x?: number, y?: number, width?: number, height?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Ellipse; + + /** + * Creates a new Grid Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Grid Game Object has been built into Phaser. + * + * The Grid Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * A Grid Shape allows you to display a grid in your game, where you can control the size of the + * grid as well as the width and height of the grid cells. You can set a fill color for each grid + * cell as well as an alternate fill color. When the alternate fill color is set then the grid + * cells will alternate the fill colors as they render, creating a chess-board effect. You can + * also optionally have an outline fill color. If set, this draws lines between the grid cells + * in the given color. If you specify an outline color with an alpha of zero, then it will draw + * the cells spaced out, but without the lines between them. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param width The width of the grid. Default 128. + * @param height The height of the grid. Default 128. + * @param cellWidth The width of one cell in the grid. Default 32. + * @param cellHeight The height of one cell in the grid. Default 32. + * @param fillColor The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param outlineFillColor The color of the lines between the grid cells. + * @param outlineFillAlpha The alpha of the lines between the grid cells. + */ + grid(x?: number, y?: number, width?: number, height?: number, cellWidth?: number, cellHeight?: number, fillColor?: number, fillAlpha?: number, outlineFillColor?: number, outlineFillAlpha?: number): Phaser.GameObjects.Grid; + + /** + * Creates a new IsoBox Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the IsoBox Game Object has been built into Phaser. + * + * The IsoBox Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoBox is an 'isometric' rectangle. Each face of it has a different fill color. You can set + * the color of the top, left and right faces of the rectangle respectively. You can also choose + * which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoBox from under-neath, however you can change the 'angle' by setting + * the `projection` property. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param size The width of the iso box in pixels. The left and right faces will be exactly half this value. Default 48. + * @param height The height of the iso box. The left and right faces will be this tall. The overall height of the isobox will be this value plus half the `size` value. Default 32. + * @param fillTop The fill color of the top face of the iso box. Default 0xeeeeee. + * @param fillLeft The fill color of the left face of the iso box. Default 0x999999. + * @param fillRight The fill color of the right face of the iso box. Default 0xcccccc. + */ + isobox(x?: number, y?: number, size?: number, height?: number, fillTop?: number, fillLeft?: number, fillRight?: number): Phaser.GameObjects.IsoBox; + + /** + * Creates a new IsoTriangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the IsoTriangle Game Object has been built into Phaser. + * + * The IsoTriangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoTriangle is an 'isometric' triangle. Think of it like a pyramid. Each face has a different + * fill color. You can set the color of the top, left and right faces of the triangle respectively + * You can also choose which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoTriangle from under-neath, however you can change the 'angle' by setting + * the `projection` property. The `reversed` property controls if the IsoTriangle is rendered upside + * down or not. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param size The width of the iso triangle in pixels. The left and right faces will be exactly half this value. Default 48. + * @param height The height of the iso triangle. The left and right faces will be this tall. The overall height of the iso triangle will be this value plus half the `size` value. Default 32. + * @param reversed Is the iso triangle upside down? Default false. + * @param fillTop The fill color of the top face of the iso triangle. Default 0xeeeeee. + * @param fillLeft The fill color of the left face of the iso triangle. Default 0x999999. + * @param fillRight The fill color of the right face of the iso triangle. Default 0xcccccc. + */ + isotriangle(x?: number, y?: number, size?: number, height?: number, reversed?: boolean, fillTop?: number, fillLeft?: number, fillRight?: number): Phaser.GameObjects.IsoTriangle; + + /** + * Creates a new Line Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Line Game Object has been built into Phaser. + * + * The Line Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only stroke colors and cannot be filled. + * + * A Line Shape allows you to draw a line between two points in your game. You can control the + * stroke color and thickness of the line. In WebGL only you can also specify a different + * thickness for the start and end of the line, allowing you to render lines that taper-off. + * + * If you need to draw multiple lines in a sequence you may wish to use the Polygon Shape instead. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param x1 The horizontal position of the start of the line. Default 0. + * @param y1 The vertical position of the start of the line. Default 0. + * @param x2 The horizontal position of the end of the line. Default 128. + * @param y2 The vertical position of the end of the line. Default 0. + * @param strokeColor The color the line will be drawn in, i.e. 0xff0000 for red. + * @param strokeAlpha The alpha the line will be drawn in. You can also set the alpha of the overall Shape using its `alpha` property. + */ + line(x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, strokeColor?: number, strokeAlpha?: number): Phaser.GameObjects.Line; + + /** + * Creates a new Polygon Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Polygon Game Object has been built into Phaser. + * + * The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Polygon Shape is created by providing a list of points, which are then used to create an + * internal Polygon geometry object. The points can be set from a variety of formats: + * + * - An array of Point or Vector2 objects: `[new Phaser.Math.Vector2(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending + * on the coordinates of the points provided, the final shape may be rendered offset from its origin. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param points The points that make up the polygon. + * @param fillColor The color the polygon will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + polygon(x?: number, y?: number, points?: any, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Polygon; + + /** + * Creates a new Rectangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Rectangle Game Object has been built into Phaser. + * + * The Rectangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * You can change the size of the rectangle by changing the `width` and `height` properties. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param width The width of the rectangle. Default 128. + * @param height The height of the rectangle. Default 128. + * @param fillColor The color the rectangle will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the rectangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + rectangle(x?: number, y?: number, width?: number, height?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Rectangle; + + /** + * Creates a new Star Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Star Game Object has been built into Phaser. + * + * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * As the name implies, the Star shape will display a star in your game. You can control several + * aspects of it including the number of points that constitute the star. The default is 5. If + * you change it to 4 it will render as a diamond. If you increase them, you'll get a more spiky + * star shape. + * + * You can also control the inner and outer radius, which is how 'long' each point of the star is. + * Modify these values to create more interesting shapes. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param points The number of points on the star. Default 5. + * @param innerRadius The inner radius of the star. Default 32. + * @param outerRadius The outer radius of the star. Default 64. + * @param fillColor The color the star will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the star will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + star(x?: number, y?: number, points?: number, innerRadius?: number, outerRadius?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Star; + + /** + * Creates a new Triangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Triangle Game Object has been built into Phaser. + * + * The Triangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Triangle consists of 3 lines, joining up to form a triangular shape. You can control the + * position of each point of these lines. The triangle is always closed and cannot have an open + * face. If you require that, consider using a Polygon instead. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param x1 The horizontal position of the first point in the triangle. Default 0. + * @param y1 The vertical position of the first point in the triangle. Default 128. + * @param x2 The horizontal position of the second point in the triangle. Default 64. + * @param y2 The vertical position of the second point in the triangle. Default 0. + * @param x3 The horizontal position of the third point in the triangle. Default 128. + * @param y3 The vertical position of the third point in the triangle. Default 128. + * @param fillColor The color the triangle will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the triangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + triangle(x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Triangle; + + /** + * Creates a new Sprite Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Sprite Game Object has been built into Phaser. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Game Object is rendering with. + */ + sprite(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.Sprite; + + /** + * Creates a new Text Game Object and adds it to the Scene. + * + * A Text Game Object. + * + * Text objects work by creating their own internal hidden Canvas and then renders text to it using + * the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered + * to your game during the render pass. + * + * Because it uses the Canvas API you can take advantage of all the features this offers, such as + * applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts + * loaded externally, such as Google or TypeKit Web fonts. + * + * You can only display fonts that are currently loaded and available to the browser: therefore fonts must + * be pre-loaded. Phaser does not do ths for you, so you will require the use of a 3rd party font loader, + * or have the fonts ready available in the CSS on the page in which your Phaser game resides. + * + * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts + * across mobile browsers. + * + * A note on performance: Every time the contents of a Text object changes, i.e. changing the text being + * displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the + * new texture to the GPU. This can be an expensive operation if used often, or with large quantities of + * Text objects in your game. If you run into performance issues you would be better off using Bitmap Text + * instead, as it benefits from batching and avoids expensive Canvas API calls. + * + * Note: This method will only be available if the Text Game Object has been built into Phaser. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param text The text this Text object will display. + * @param style The Text style configuration object. + */ + text(x: number, y: number, text: string | string[], style?: Phaser.Types.GameObjects.Text.TextStyle): Phaser.GameObjects.Text; + + /** + * Creates a new TileSprite Game Object and adds it to the Scene. + * + * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param width The width of the Game Object. If zero it will use the size of the texture frame. + * @param height The height of the Game Object. If zero it will use the size of the texture frame. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Game Object is rendering with. + */ + tileSprite(x: number, y: number, width: number, height: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.TileSprite; + + /** + * Creates a new Video Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Video Game Object has been built into Phaser. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param key Optional key of the Video this Game Object will play, as stored in the Video Cache. + */ + video(x: number, y: number, key?: string): Phaser.GameObjects.Video; + + /** + * Creates a new Zone Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Zone Game Object has been built into Phaser. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param width The width of the Game Object. + * @param height The height of the Game Object. + */ + zone(x: number, y: number, width: number, height: number): Phaser.GameObjects.Zone; + + /** + * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. + * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing + * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map + * data. For an empty map, you should specify tileWidth, tileHeight, width & height. + * @param key The key in the Phaser cache that corresponds to the loaded tilemap data. + * @param tileWidth The width of a tile in pixels. Pass in `null` to leave as the + * default. Default 32. + * @param tileHeight The height of a tile in pixels. Pass in `null` to leave as the + * default. Default 32. + * @param width The width of the map in tiles. Pass in `null` to leave as the + * default. Default 10. + * @param height The height of the map in tiles. Pass in `null` to leave as the + * default. Default 10. + * @param data Instead of loading from the cache, you can also load directly from + * a 2D array of tile indexes. Pass in `null` for no data. + * @param insertNull Controls how empty tiles, tiles with an index of -1, in the + * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. Default false. + */ + tilemap(key?: string, tileWidth?: number, tileHeight?: number, width?: number, height?: number, data?: number[][], insertNull?: boolean): Phaser.Tilemaps.Tilemap; + + /** + * Creates a new Tween object. + * + * Note: This method will only be available if Tweens have been built into Phaser. + * @param config The Tween configuration. + */ + tween(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.Tween; + + } + + /** + * Calculates the Transform Matrix of the given Game Object and Camera, factoring in + * the parent matrix if provided. + * + * Note that the object this results contains _references_ to the Transform Matrices, + * not new instances of them. Therefore, you should use their values immediately, or + * copy them to your own matrix, as they will be replaced as soon as another Game + * Object is rendered. + * @param src The Game Object to calculate the transform matrix for. + * @param camera The camera being used to render the Game Object. + * @param parentMatrix The transform matrix of the parent container, if any. + */ + function GetCalcMatrix(src: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Types.GameObjects.GetCalcMatrixResults; + + /** + * The Update List plugin. + * + * Update Lists belong to a Scene and maintain the list Game Objects to be updated every frame. + * + * Some or all of these Game Objects may also be part of the Scene's [Display List]{@link Phaser.GameObjects.DisplayList}, for Rendering. + */ + class UpdateList extends Phaser.Structs.ProcessQueue { + /** + * + * @param scene The Scene that the Update List belongs to. + */ + constructor(scene: Phaser.Scene); + + /** + * The Scene that the Update List belongs to. + */ + scene: Phaser.Scene; + + /** + * The Scene's Systems. + */ + systems: Phaser.Scenes.Systems; + + /** + * The update step. + * + * Pre-updates every active Game Object in the list. + * @param time The current timestamp. + * @param delta The delta time elapsed since the last frame. + */ + sceneUpdate(time: number, delta: number): void; + + /** + * The Scene that owns this plugin is shutting down. + * + * We need to kill and reset all internal properties as well as stop listening to Scene events. + */ + shutdown(): void; + + /** + * The Scene that owns this plugin is being destroyed. + * + * We need to shutdown and then kill off all external references. + */ + destroy(): void; + + } + + namespace RetroFont { + /** + * Parses a Retro Font configuration object so you can pass it to the BitmapText constructor + * and create a BitmapText object using a fixed-width retro font. + * @param scene A reference to the Phaser Scene. + * @param config The font configuration object. + */ + function Parse(scene: Phaser.Scene, config: Phaser.Types.GameObjects.BitmapText.RetroFontConfig): object; + + /** + * Text Set 1 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ + */ + var TEXT_SET1: string; + + /** + * Text Set 2 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ + */ + var TEXT_SET2: string; + + /** + * Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 + */ + var TEXT_SET3: string; + + /** + * Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 + */ + var TEXT_SET4: string; + + /** + * Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789 + */ + var TEXT_SET5: string; + + /** + * Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.' + */ + var TEXT_SET6: string; + + /** + * Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-'39 + */ + var TEXT_SET7: string; + + /** + * Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ + */ + var TEXT_SET8: string; + + /** + * Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'"?! + */ + var TEXT_SET9: string; + + /** + * Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ + */ + var TEXT_SET10: string; + + /** + * Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()':;0123456789 + */ + var TEXT_SET11: string; + + } + /** * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. * @@ -10469,72 +12148,6 @@ declare namespace Phaser { } - namespace RetroFont { - /** - * Text Set 1 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ - */ - var TEXT_SET1: string; - - /** - * Text Set 2 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ - */ - var TEXT_SET2: string; - - /** - * Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 - */ - var TEXT_SET3: string; - - /** - * Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 - */ - var TEXT_SET4: string; - - /** - * Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789 - */ - var TEXT_SET5: string; - - /** - * Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.' - */ - var TEXT_SET6: string; - - /** - * Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-'39 - */ - var TEXT_SET7: string; - - /** - * Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ - */ - var TEXT_SET8: string; - - /** - * Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'"?! - */ - var TEXT_SET9: string; - - /** - * Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ - */ - var TEXT_SET10: string; - - /** - * Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()':;0123456789 - */ - var TEXT_SET11: string; - - /** - * Parses a Retro Font configuration object so you can pass it to the BitmapText constructor - * and create a BitmapText object using a fixed-width retro font. - * @param scene A reference to the Phaser Scene. - * @param config The font configuration object. - */ - function Parse(scene: Phaser.Scene, config: Phaser.Types.GameObjects.BitmapText.RetroFontConfig): object; - - } - /** * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. * @@ -10614,6 +12227,11 @@ declare namespace Phaser { */ dropShadowAlpha: number; + /** + * Indicates whether the font texture is from an atlas or not. + */ + readonly fromAtlas: boolean; + /** * Set the lines of text in this BitmapText to be left-aligned. * This only has any effect if this BitmapText contains more than one line of text. @@ -12589,21 +14207,6 @@ declare namespace Phaser { } - /** - * Builds a Game Object using the provided configuration object. - * @param scene A reference to the Scene. - * @param gameObject The initial GameObject. - * @param config The config to build the GameObject with. - */ - function BuildGameObject(scene: Phaser.Scene, gameObject: Phaser.GameObjects.GameObject, config: Phaser.Types.GameObjects.GameObjectConfig): Phaser.GameObjects.GameObject; - - /** - * Adds an Animation component to a Sprite and populates it based on the given config. - * @param sprite The sprite to add an Animation component to. - * @param config The animation config. - */ - function BuildGameObjectAnimation(sprite: Phaser.GameObjects.Sprite, config: object): Phaser.GameObjects.Sprite; - namespace Components { /** * Provides methods used for setting the alpha properties of a Game Object. @@ -14134,7 +15737,7 @@ declare namespace Phaser { * * The position of the Game Object automatically becomes relative to the position of the Container. * - * The origin of a Container is 0x0 (in local space) and that cannot be changed. The children you add to the + * The transform point of a Container is 0x0 (in local space) and that cannot be changed. The children you add to the * Container should be positioned with this value in mind. I.e. you should treat 0x0 as being the center of * the Container, and position children positively and negative around it as required. * @@ -15168,65 +16771,6 @@ declare namespace Phaser { } - /** - * The Display List plugin. - * - * Display Lists belong to a Scene and maintain the list of Game Objects to render every frame. - * - * Some of these Game Objects may also be part of the Scene's [Update List]{@link Phaser.GameObjects.UpdateList}, for updating. - */ - class DisplayList extends Phaser.Structs.List { - /** - * - * @param scene The Scene that this Display List belongs to. - */ - constructor(scene: Phaser.Scene); - - /** - * The flag the determines whether Game Objects should be sorted when `depthSort()` is called. - */ - sortChildrenFlag: boolean; - - /** - * The Scene that this Display List belongs to. - */ - scene: Phaser.Scene; - - /** - * The Scene's Systems. - */ - systems: Phaser.Scenes.Systems; - - /** - * The Scene's Event Emitter. - */ - events: Phaser.Events.EventEmitter; - - /** - * Force a sort of the display list on the next call to depthSort. - */ - queueDepthSort(): void; - - /** - * Immediately sorts the display list if the flag is set. - */ - depthSort(): void; - - /** - * Compare the depth of two Game Objects. - * @param childA The first Game Object. - * @param childB The second Game Object. - */ - sortByDepth(childA: Phaser.GameObjects.GameObject, childB: Phaser.GameObjects.GameObject): number; - - /** - * Returns an array which contains all objects currently on the Display List. - * This is a reference to the main list array, not a copy of it, so be careful not to modify it. - */ - getChildren(): Phaser.GameObjects.GameObject[]; - - } - /** * DOM Element Game Objects are a way to control and manipulate HTML Elements over the top of your game. * @@ -16940,1496 +18484,6 @@ declare namespace Phaser { } - /** - * The base class that all Game Objects extend. - * You don't create GameObjects directly and they cannot be added to the display list. - * Instead, use them as the base for your own custom classes. - */ - class GameObject extends Phaser.Events.EventEmitter { - /** - * - * @param scene The Scene to which this Game Object belongs. - * @param type A textual representation of the type of Game Object, i.e. `sprite`. - */ - constructor(scene: Phaser.Scene, type: string); - - /** - * A reference to the Scene to which this Game Object belongs. - * - * Game Objects can only belong to one Scene. - * - * You should consider this property as being read-only. You cannot move a - * Game Object to another Scene by simply changing it. - */ - scene: Phaser.Scene; - - /** - * Holds a reference to the Display List that contains this Game Object. - * - * This is set automatically when this Game Object is added to a Scene or Layer. - * - * You should treat this property as being read-only. - */ - displayList: Phaser.GameObjects.DisplayList | Phaser.GameObjects.Layer; - - /** - * A textual representation of this Game Object, i.e. `sprite`. - * Used internally by Phaser but is available for your own custom classes to populate. - */ - type: string; - - /** - * The current state of this Game Object. - * - * Phaser itself will never modify this value, although plugins may do so. - * - * Use this property to track the state of a Game Object during its lifetime. For example, it could change from - * a state of 'moving', to 'attacking', to 'dead'. The state value should be an integer (ideally mapped to a constant - * in your game code), or a string. These are recommended to keep it light and simple, with fast comparisons. - * If you need to store complex data about your Game Object, look at using the Data Component instead. - */ - state: number | string; - - /** - * The parent Container of this Game Object, if it has one. - */ - parentContainer: Phaser.GameObjects.Container; - - /** - * The name of this Game Object. - * Empty by default and never populated by Phaser, this is left for developers to use. - */ - name: string; - - /** - * The active state of this Game Object. - * A Game Object with an active state of `true` is processed by the Scenes UpdateList, if added to it. - * An active object is one which is having its logic and internal systems updated. - */ - active: boolean; - - /** - * The Tab Index of the Game Object. - * Reserved for future use by plugins and the Input Manager. - */ - tabIndex: number; - - /** - * A Data Manager. - * It allows you to store, query and get key/value paired information specific to this Game Object. - * `null` by default. Automatically created if you use `getData` or `setData` or `setDataEnabled`. - */ - data: Phaser.Data.DataManager; - - /** - * The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not. - * The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively. - * If those components are not used by your custom class then you can use this bitmask as you wish. - */ - renderFlags: number; - - /** - * A bitmask that controls if this Game Object is drawn by a Camera or not. - * Not usually set directly, instead call `Camera.ignore`, however you can - * set this property directly using the Camera.id property: - */ - cameraFilter: number; - - /** - * If this Game Object is enabled for input then this property will contain an InteractiveObject instance. - * Not usually set directly. Instead call `GameObject.setInteractive()`. - */ - input: Phaser.Types.Input.InteractiveObject; - - /** - * If this Game Object is enabled for Arcade or Matter Physics then this property will contain a reference to a Physics Body. - */ - body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody | MatterJS.BodyType; - - /** - * This Game Object will ignore all calls made to its destroy method if this flag is set to `true`. - * This includes calls that may come from a Group, Container or the Scene itself. - * While it allows you to persist a Game Object across Scenes, please understand you are entirely - * responsible for managing references to and from this Game Object. - */ - ignoreDestroy: boolean; - - /** - * Sets the `active` property of this Game Object and returns this Game Object for further chaining. - * A Game Object with its `active` property set to `true` will be updated by the Scenes UpdateList. - * @param value True if this Game Object should be set as active, false if not. - */ - setActive(value: boolean): this; - - /** - * Sets the `name` property of this Game Object and returns this Game Object for further chaining. - * The `name` property is not populated by Phaser and is presented for your own use. - * @param value The name to be given to this Game Object. - */ - setName(value: string): this; - - /** - * Sets the current state of this Game Object. - * - * Phaser itself will never modify the State of a Game Object, although plugins may do so. - * - * For example, a Game Object could change from a state of 'moving', to 'attacking', to 'dead'. - * The state value should typically be an integer (ideally mapped to a constant - * in your game code), but could also be a string. It is recommended to keep it light and simple. - * If you need to store complex data about your Game Object, look at using the Data Component instead. - * @param value The state of the Game Object. - */ - setState(value: number | string): this; - - /** - * Adds a Data Manager component to this Game Object. - */ - setDataEnabled(): this; - - /** - * Allows you to store a key value pair within this Game Objects Data Manager. - * - * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled - * before setting the value. - * - * If the key doesn't already exist in the Data Manager then it is created. - * - * ```javascript - * sprite.setData('name', 'Red Gem Stone'); - * ``` - * - * You can also pass in an object of key value pairs as the first argument: - * - * ```javascript - * sprite.setData({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); - * ``` - * - * To get a value back again you can call `getData`: - * - * ```javascript - * sprite.getData('gold'); - * ``` - * - * Or you can access the value directly via the `values` property, where it works like any other variable: - * - * ```javascript - * sprite.data.values.gold += 50; - * ``` - * - * When the value is first set, a `setdata` event is emitted from this Game Object. - * - * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. - * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata-PlayerLives`. - * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. - * - * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. - * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. - * @param key The key to set the value for. Or an object of key value pairs. If an object the `data` argument is ignored. - * @param data The value to set for the given key. If an object is provided as the key this argument is ignored. - */ - setData(key: string | object, data?: any): this; - - /** - * Increase a value for the given key within this Game Objects Data Manager. If the key doesn't already exist in the Data Manager then it is increased from 0. - * - * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled - * before setting the value. - * - * If the key doesn't already exist in the Data Manager then it is created. - * - * When the value is first set, a `setdata` event is emitted from this Game Object. - * @param key The key to increase the value for. - * @param data The value to increase for the given key. - */ - incData(key: string | object, data?: any): this; - - /** - * Toggle a boolean value for the given key within this Game Objects Data Manager. If the key doesn't already exist in the Data Manager then it is toggled from false. - * - * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled - * before setting the value. - * - * If the key doesn't already exist in the Data Manager then it is created. - * - * When the value is first set, a `setdata` event is emitted from this Game Object. - * @param key The key to toggle the value for. - */ - toggleData(key: string | object): this; - - /** - * Retrieves the value for the given key in this Game Objects Data Manager, or undefined if it doesn't exist. - * - * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: - * - * ```javascript - * sprite.getData('gold'); - * ``` - * - * Or access the value directly: - * - * ```javascript - * sprite.data.values.gold; - * ``` - * - * You can also pass in an array of keys, in which case an array of values will be returned: - * - * ```javascript - * sprite.getData([ 'gold', 'armor', 'health' ]); - * ``` - * - * This approach is useful for destructuring arrays in ES6. - * @param key The key of the value to retrieve, or an array of keys. - */ - getData(key: string | string[]): any; - - /** - * Pass this Game Object to the Input Manager to enable it for Input. - * - * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area - * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced - * input detection. - * - * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If - * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific - * shape for it to use. - * - * You can also provide an Input Configuration Object as the only argument to this method. - * @param hitArea Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not given it will try to create a Rectangle based on the texture frame. - * @param callback The callback that determines if the pointer is within the Hit Area shape or not. If you provide a shape you must also provide a callback. - * @param dropZone Should this Game Object be treated as a drop zone target? Default false. - */ - setInteractive(hitArea?: Phaser.Types.Input.InputConfiguration | any, callback?: Phaser.Types.Input.HitAreaCallback, dropZone?: boolean): this; - - /** - * If this Game Object has previously been enabled for input, this will disable it. - * - * An object that is disabled for input stops processing or being considered for - * input events, but can be turned back on again at any time by simply calling - * `setInteractive()` with no arguments provided. - * - * If want to completely remove interaction from this Game Object then use `removeInteractive` instead. - */ - disableInteractive(): this; - - /** - * If this Game Object has previously been enabled for input, this will queue it - * for removal, causing it to no longer be interactive. The removal happens on - * the next game step, it is not immediate. - * - * The Interactive Object that was assigned to this Game Object will be destroyed, - * removed from the Input Manager and cleared from this Game Object. - * - * If you wish to re-enable this Game Object at a later date you will need to - * re-create its InteractiveObject by calling `setInteractive` again. - * - * If you wish to only temporarily stop an object from receiving input then use - * `disableInteractive` instead, as that toggles the interactive state, where-as - * this erases it completely. - * - * If you wish to resize a hit area, don't remove and then set it as being - * interactive. Instead, access the hitarea object directly and resize the shape - * being used. I.e.: `sprite.input.hitArea.setSize(width, height)` (assuming the - * shape is a Rectangle, which it is by default.) - */ - removeInteractive(): this; - - /** - * This callback is invoked when this Game Object is added to a Scene. - * - * Can be overriden by custom Game Objects, but be aware of some Game Objects that - * will use this, such as Sprites, to add themselves into the Update List. - * - * You can also listen for the `ADDED_TO_SCENE` event from this Game Object. - */ - addedToScene(): void; - - /** - * This callback is invoked when this Game Object is removed from a Scene. - * - * Can be overriden by custom Game Objects, but be aware of some Game Objects that - * will use this, such as Sprites, to removed themselves from the Update List. - * - * You can also listen for the `REMOVED_FROM_SCENE` event from this Game Object. - */ - removedFromScene(): void; - - /** - * To be overridden by custom GameObjects. Allows base objects to be used in a Pool. - * @param args args - */ - update(...args: any[]): void; - - /** - * Returns a JSON representation of the Game Object. - */ - toJSON(): Phaser.Types.GameObjects.JSONGameObject; - - /** - * Compares the renderMask with the renderFlags to see if this Game Object will render or not. - * Also checks the Game Object against the given Cameras exclusion list. - * @param camera The Camera to check against this Game Object. - */ - willRender(camera: Phaser.Cameras.Scene2D.Camera): boolean; - - /** - * Returns an array containing the display list index of either this Game Object, or if it has one, - * its parent Container. It then iterates up through all of the parent containers until it hits the - * root of the display list (which is index 0 in the returned array). - * - * Used internally by the InputPlugin but also useful if you wish to find out the display depth of - * this Game Object and all of its ancestors. - */ - getIndexList(): number[]; - - /** - * Adds this Game Object to the given Display List. - * - * If no Display List is specified, it will default to the Display List owned by the Scene to which - * this Game Object belongs. - * - * A Game Object can only exist on one Display List at any given time, but may move freely between them. - * - * If this Game Object is already on another Display List when this method is called, it will first - * be removed from it, before being added to the new list. - * - * You can query which list it is on by looking at the `Phaser.GameObjects.GameObject#displayList` property. - * - * If a Game Object isn't on any display list, it will not be rendered. If you just wish to temporarly - * disable it from rendering, consider using the `setVisible` method, instead. - * @param displayList The Display List to add to. Defaults to the Scene Display List. - */ - addToDisplayList(displayList?: Phaser.GameObjects.DisplayList | Phaser.GameObjects.Layer): this; - - /** - * Adds this Game Object to the Update List belonging to the Scene. - * - * When a Game Object is added to the Update List it will have its `preUpdate` method called - * every game frame. This method is passed two parameters: `delta` and `time`. - * - * If you wish to run your own logic within `preUpdate` then you should always call - * `preUpdate.super(delta, time)` within it, or it may fail to process required operations, - * such as Sprite animations. - */ - addToUpdateList(): this; - - /** - * Removes this Game Object from the Display List it is currently on. - * - * A Game Object can only exist on one Display List at any given time, but may move freely removed - * and added back at a later stage. - * - * You can query which list it is on by looking at the `Phaser.GameObjects.GameObject#displayList` property. - * - * If a Game Object isn't on any Display List, it will not be rendered. If you just wish to temporarly - * disable it from rendering, consider using the `setVisible` method, instead. - */ - removeFromDisplayList(): this; - - /** - * Removes this Game Object from the Scene's Update List. - * - * When a Game Object is on the Update List, it will have its `preUpdate` method called - * every game frame. Calling this method will remove it from the list, preventing this. - * - * Removing a Game Object from the Update List will stop most internal functions working. - * For example, removing a Sprite from the Update List will prevent it from being able to - * run animations. - */ - removeFromUpdateList(): this; - - /** - * Destroys this Game Object removing it from the Display List and Update List and - * severing all ties to parent resources. - * - * Also removes itself from the Input Manager and Physics Manager if previously enabled. - * - * Use this to remove a Game Object from your game if you don't ever plan to use it again. - * As long as no reference to it exists within your own code it should become free for - * garbage collection by the browser. - * - * If you just want to temporarily disable an object then look at using the - * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. - */ - destroy(): void; - - /** - * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not. - */ - static readonly RENDER_MASK: number; - - } - - /** - * The Game Object Creator is a Scene plugin that allows you to quickly create many common - * types of Game Objects and return them. Unlike the Game Object Factory, they are not automatically - * added to the Scene. - * - * Game Objects directly register themselves with the Creator and inject their own creation - * methods into the class. - */ - class GameObjectCreator { - /** - * - * @param scene The Scene to which this Game Object Factory belongs. - */ - constructor(scene: Phaser.Scene); - - /** - * Creates a new Dynamic Bitmap Text Game Object and returns it. - * - * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - dynamicBitmapText(config: Phaser.Types.GameObjects.BitmapText.BitmapTextConfig, addToScene?: boolean): Phaser.GameObjects.DynamicBitmapText; - - /** - * Creates a new Bitmap Text Game Object and returns it. - * - * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - bitmapText(config: Phaser.Types.GameObjects.BitmapText.BitmapTextConfig, addToScene?: boolean): Phaser.GameObjects.BitmapText; - - /** - * Creates a new Blitter Game Object and returns it. - * - * Note: This method will only be available if the Blitter Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - blitter(config: object, addToScene?: boolean): Phaser.GameObjects.Blitter; - - /** - * Creates a new Container Game Object and returns it. - * - * Note: This method will only be available if the Container Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - container(config: object, addToScene?: boolean): Phaser.GameObjects.Container; - - /** - * The Scene to which this Game Object Creator belongs. - */ - protected scene: Phaser.Scene; - - /** - * A reference to the Scene.Systems. - */ - protected systems: Phaser.Scenes.Systems; - - /** - * A reference to the Scene Event Emitter. - */ - protected events: Phaser.Events.EventEmitter; - - /** - * A reference to the Scene Display List. - */ - protected displayList: Phaser.GameObjects.DisplayList; - - /** - * A reference to the Scene Update List. - */ - protected updateList: Phaser.GameObjects.UpdateList; - - /** - * Creates a new Graphics Game Object and returns it. - * - * Note: This method will only be available if the Graphics Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - graphics(config: object, addToScene?: boolean): Phaser.GameObjects.Graphics; - - /** - * Creates a new Group Game Object and returns it. - * - * Note: This method will only be available if the Group Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - */ - group(config: Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig): Phaser.GameObjects.Group; - - /** - * Creates a new Image Game Object and returns it. - * - * Note: This method will only be available if the Image Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - image(config: object, addToScene?: boolean): Phaser.GameObjects.Image; - - /** - * Creates a new Layer Game Object and returns it. - * - * Note: This method will only be available if the Layer Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - layer(config: object, addToScene?: boolean): Phaser.GameObjects.Layer; - - /** - * Creates a new Mesh Game Object and returns it. - * - * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - mesh(config: object, addToScene?: boolean): Phaser.GameObjects.Mesh; - - /** - * Creates a new Particle Emitter Manager Game Object and returns it. - * - * Note: This method will only be available if the Particles Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - particles(config: object, addToScene?: boolean): Phaser.GameObjects.Particles.ParticleEmitterManager; - - /** - * Creates a new Point Light Game Object and returns it. - * - * Note: This method will only be available if the Point Light Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - pointlight(config: object, addToScene?: boolean): Phaser.GameObjects.PointLight; - - /** - * Creates a new Render Texture Game Object and returns it. - * - * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - renderTexture(config: Phaser.Types.GameObjects.RenderTexture.RenderTextureConfig, addToScene?: boolean): Phaser.GameObjects.RenderTexture; - - /** - * Creates a new Rope Game Object and returns it. - * - * Note: This method will only be available if the Rope Game Object and WebGL support have been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - rope(config: object, addToScene?: boolean): Phaser.GameObjects.Rope; - - /** - * Creates a new Shader Game Object and returns it. - * - * Note: This method will only be available if the Shader Game Object and WebGL support have been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - shader(config: object, addToScene?: boolean): Phaser.GameObjects.Shader; - - /** - * Creates a new Sprite Game Object and returns it. - * - * Note: This method will only be available if the Sprite Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - sprite(config: Phaser.Types.GameObjects.Sprite.SpriteConfig, addToScene?: boolean): Phaser.GameObjects.Sprite; - - /** - * Creates a new Text Game Object and returns it. - * - * Note: This method will only be available if the Text Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - text(config: Phaser.Types.GameObjects.Text.TextConfig, addToScene?: boolean): Phaser.GameObjects.Text; - - /** - * Creates a new TileSprite Game Object and returns it. - * - * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - tileSprite(config: Phaser.Types.GameObjects.TileSprite.TileSpriteConfig, addToScene?: boolean): Phaser.GameObjects.TileSprite; - - /** - * Creates a new Video Game Object and returns it. - * - * Note: This method will only be available if the Video Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - video(config: object, addToScene?: boolean): Phaser.GameObjects.Video; - - /** - * Creates a new Zone Game Object and returns it. - * - * Note: This method will only be available if the Zone Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - */ - zone(config: object): Phaser.GameObjects.Zone; - - /** - * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. - * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing - * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map - * data. For an empty map, you should specify tileWidth, tileHeight, width & height. - * @param config The config options for the Tilemap. - */ - tilemap(config?: Phaser.Types.Tilemaps.TilemapConfig): Phaser.Tilemaps.Tilemap; - - /** - * Creates a new Tween object and returns it. - * - * Note: This method will only be available if Tweens have been built into Phaser. - * @param config The Tween configuration. - */ - tween(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.Tween; - - } - - /** - * The Game Object Factory is a Scene plugin that allows you to quickly create many common - * types of Game Objects and have them automatically registered with the Scene. - * - * Game Objects directly register themselves with the Factory and inject their own creation - * methods into the class. - */ - class GameObjectFactory { - /** - * - * @param scene The Scene to which this Game Object Factory belongs. - */ - constructor(scene: Phaser.Scene); - - /** - * Creates a new Path Object. - * @param x The horizontal position of this Path. - * @param y The vertical position of this Path. - */ - path(x: number, y: number): Phaser.Curves.Path; - - /** - * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. - * - * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. - * - * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to - * match the font structure. - * - * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each - * letter being rendered during the render pass. This callback allows you to manipulate the properties of - * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects - * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing - * time, so only use them if you require the callback ability they have. - * - * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability - * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by - * processing the font texture in an image editor, applying fills and any other effects required. - * - * To create multi-line text insert \r, \n or \r\n escape codes into the text string. - * - * To create a BitmapText data files you need a 3rd party app such as: - * - * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ - * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner - * Littera (Web-based, free): http://kvazars.com/littera/ - * - * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of - * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson - * - * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. - * @param x The x position of the Game Object. - * @param y The y position of the Game Object. - * @param font The key of the font to use from the BitmapFont cache. - * @param text The string, or array of strings, to be set as the content of this Bitmap Text. - * @param size The font size to set. - */ - dynamicBitmapText(x: number, y: number, font: string, text?: string | string[], size?: number): Phaser.GameObjects.DynamicBitmapText; - - /** - * Creates a new Bitmap Text Game Object and adds it to the Scene. - * - * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. - * - * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to - * match the font structure. - * - * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability - * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by - * processing the font texture in an image editor, applying fills and any other effects required. - * - * To create multi-line text insert \r, \n or \r\n escape codes into the text string. - * - * To create a BitmapText data files you need a 3rd party app such as: - * - * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ - * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner - * Littera (Web-based, free): http://kvazars.com/littera/ - * - * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of - * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson - * - * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. - * @param x The x position of the Game Object. - * @param y The y position of the Game Object. - * @param font The key of the font to use from the BitmapFont cache. - * @param text The string, or array of strings, to be set as the content of this Bitmap Text. - * @param size The font size to set. - * @param align The alignment of the text in a multi-line BitmapText object. Default 0. - */ - bitmapText(x: number, y: number, font: string, text?: string | string[], size?: number, align?: number): Phaser.GameObjects.BitmapText; - - /** - * Creates a new Blitter Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Blitter Game Object has been built into Phaser. - * @param x The x position of the Game Object. - * @param y The y position of the Game Object. - * @param key The key of the Texture the Blitter object will use. - * @param frame The default Frame children of the Blitter will use. - */ - blitter(x: number, y: number, key: string, frame?: string | number): Phaser.GameObjects.Blitter; - - /** - * Creates a new Container Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Container Game Object has been built into Phaser. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param children An optional array of Game Objects to add to this Container. - */ - container(x?: number, y?: number, children?: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[]): Phaser.GameObjects.Container; - - /** - * DOM Element Game Objects are a way to control and manipulate HTML Elements over the top of your game. - * - * In order for DOM Elements to display you have to enable them by adding the following to your game - * configuration object: - * - * ```javascript - * dom { - * createContainer: true - * } - * ``` - * - * When this is added, Phaser will automatically create a DOM Container div that is positioned over the top - * of the game canvas. This div is sized to match the canvas, and if the canvas size changes, as a result of - * settings within the Scale Manager, the dom container is resized accordingly. - * - * You can create a DOM Element by either passing in DOMStrings, or by passing in a reference to an existing - * Element that you wish to be placed under the control of Phaser. For example: - * - * ```javascript - * this.add.dom(x, y, 'div', 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser'); - * ``` - * - * The above code will insert a div element into the DOM Container at the given x/y coordinate. The DOMString in - * the 4th argument sets the initial CSS style of the div and the final argument is the inner text. In this case, - * it will create a lime colored div that is 220px by 100px in size with the text Phaser in it, in an Arial font. - * - * You should nearly always, without exception, use explicitly sized HTML Elements, in order to fully control - * alignment and positioning of the elements next to regular game content. - * - * Rather than specify the CSS and HTML directly you can use the `load.html` File Loader to load it into the - * cache and then use the `createFromCache` method instead. You can also use `createFromHTML` and various other - * methods available in this class to help construct your elements. - * - * Once the element has been created you can then control it like you would any other Game Object. You can set its - * position, scale, rotation, alpha and other properties. It will move as the main Scene Camera moves and be clipped - * at the edge of the canvas. It's important to remember some limitations of DOM Elements: The obvious one is that - * they appear above or below your game canvas. You cannot blend them into the display list, meaning you cannot have - * a DOM Element, then a Sprite, then another DOM Element behind it. - * - * They also cannot be enabled for input. To do that, you have to use the `addListener` method to add native event - * listeners directly. The final limitation is to do with cameras. The DOM Container is sized to match the game canvas - * entirely and clipped accordingly. DOM Elements respect camera scrolling and scrollFactor settings, but if you - * change the size of the camera so it no longer matches the size of the canvas, they won't be clipped accordingly. - * - * Also, all DOM Elements are inserted into the same DOM Container, regardless of which Scene they are created in. - * - * DOM Elements are a powerful way to align native HTML with your Phaser Game Objects. For example, you can insert - * a login form for a multiplayer game directly into your title screen. Or a text input box for a highscore table. - * Or a banner ad from a 3rd party service. Or perhaps you'd like to use them for high resolution text display and - * UI. The choice is up to you, just remember that you're dealing with standard HTML and CSS floating over the top - * of your game, and should treat it accordingly. - * - * Note: This method will only be available if the DOM Element Game Object has been built into Phaser. - * @param x The horizontal position of this DOM Element in the world. - * @param y The vertical position of this DOM Element in the world. - * @param element An existing DOM element, or a string. If a string starting with a # it will do a `getElementById` look-up on the string (minus the hash). Without a hash, it represents the type of element to create, i.e. 'div'. - * @param style If a string, will be set directly as the elements `style` property value. If a plain object, will be iterated and the values transferred. In both cases the values replacing whatever CSS styles may have been previously set. - * @param innerText If given, will be set directly as the elements `innerText` property value, replacing whatever was there before. - */ - dom(x: number, y: number, element?: HTMLElement | string, style?: string | any, innerText?: string): Phaser.GameObjects.DOMElement; - - /** - * Creates a new Extern Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Extern Game Object has been built into Phaser. - */ - extern(): Phaser.GameObjects.Extern; - - /** - * The Scene to which this Game Object Factory belongs. - */ - protected scene: Phaser.Scene; - - /** - * A reference to the Scene.Systems. - */ - protected systems: Phaser.Scenes.Systems; - - /** - * A reference to the Scene Event Emitter. - */ - protected events: Phaser.Events.EventEmitter; - - /** - * A reference to the Scene Display List. - */ - protected displayList: Phaser.GameObjects.DisplayList; - - /** - * A reference to the Scene Update List. - */ - protected updateList: Phaser.GameObjects.UpdateList; - - /** - * Adds an existing Game Object to this Scene. - * - * If the Game Object renders, it will be added to the Display List. - * If it has a `preUpdate` method, it will be added to the Update List. - * @param child The child to be added to this Scene. - */ - existing(child: G): G; - - /** - * Static method called directly by the Game Object factory functions. - * With this method you can register a custom GameObject factory in the GameObjectFactory, - * providing a name (`factoryType`) and the constructor (`factoryFunction`) in order - * to be called when you call to Phaser.Scene.add[ factoryType ] method. - * @param factoryType The key of the factory that you will use to call to Phaser.Scene.add[ factoryType ] method. - * @param factoryFunction The constructor function to be called when you invoke to the Phaser.Scene.add method. - */ - static register(factoryType: string, factoryFunction: Function): void; - - /** - * Static method called directly by the Game Object factory functions. - * With this method you can remove a custom GameObject factory registered in the GameObjectFactory, - * providing a its `factoryType`. - * @param factoryType The key of the factory that you want to remove from the GameObjectFactory. - */ - static remove(factoryType: string): void; - - /** - * Creates a new Graphics Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Graphics Game Object has been built into Phaser. - * @param config The Graphics configuration. - */ - graphics(config?: Phaser.Types.GameObjects.Graphics.Options): Phaser.GameObjects.Graphics; - - /** - * Creates a new Group Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Group Game Object has been built into Phaser. - * @param children Game Objects to add to this Group; or the `config` argument. - * @param config A Group Configuration object. - */ - group(children?: Phaser.GameObjects.GameObject[] | Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupConfig[], config?: Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig): Phaser.GameObjects.Group; - - /** - * Creates a new Image Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Image Game Object has been built into Phaser. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. - */ - image(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.Image; - - /** - * Creates a new Layer Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Layer Game Object has been built into Phaser. - * @param children An optional array of Game Objects to add to this Layer. - */ - layer(children?: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[]): Phaser.GameObjects.Layer; - - /** - * Creates a new Mesh Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. - * @param vertices The vertices array. Either `xy` pairs, or `xyz` if the `containsZ` parameter is `true`. - * @param uvs The UVs pairs array. - * @param indicies Optional vertex indicies array. If you don't have one, pass `null` or an empty array. - * @param containsZ Does the vertices data include a `z` component? Default false. - * @param normals Optional vertex normals array. If you don't have one, pass `null` or an empty array. - * @param colors An array of colors, one per vertex, or a single color value applied to all vertices. Default 0xffffff. - * @param alphas An array of alpha values, one per vertex, or a single alpha value applied to all vertices. Default 1. - */ - mesh(x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number, vertices?: number[], uvs?: number[], indicies?: number[], containsZ?: boolean, normals?: number[], colors?: number | number[], alphas?: number | number[]): Phaser.GameObjects.Mesh; - - /** - * Creates a new Particle Emitter Manager Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Particles Game Object has been built into Phaser. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. - * @param emitters Configuration settings for one or more emitters to create. - */ - particles(texture: string | Phaser.Textures.Texture, frame?: string | number | object, emitters?: Phaser.Types.GameObjects.Particles.ParticleEmitterConfig | Phaser.Types.GameObjects.Particles.ParticleEmitterConfig[]): Phaser.GameObjects.Particles.ParticleEmitterManager; - - /** - * Creates a new PathFollower Game Object and adds it to the Scene. - * - * Note: This method will only be available if the PathFollower Game Object has been built into Phaser. - * @param path The Path this PathFollower is connected to. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. - */ - follower(path: Phaser.Curves.Path, x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.PathFollower; - - /** - * Creates a new Point Light Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Point Light Game Object has been built into Phaser. - * - * The Point Light Game Object provides a way to add a point light effect into your game, - * without the expensive shader processing requirements of the traditional Light Game Object. - * - * The difference is that the Point Light renders using a custom shader, designed to give the - * impression of a point light source, of variable radius, intensity and color, in your game. - * However, unlike the Light Game Object, it does not impact any other Game Objects, or use their - * normal maps for calcuations. This makes them extremely fast to render compared to Lights - * and perfect for special effects, such as flickering torches or muzzle flashes. - * - * For maximum performance you should batch Point Light Game Objects together. This means - * ensuring they follow each other consecutively on the display list. Ideally, use a Layer - * Game Object and then add just Point Lights to it, so that it can batch together the rendering - * of the lights. You don't _have_ to do this, and if you've only a handful of Point Lights in - * your game then it's perfectly safe to mix them into the dislay list as normal. However, if - * you're using a large number of them, please consider how they are mixed into the display list. - * - * The renderer will automatically cull Point Lights. Those with a radius that does not intersect - * with the Camera will be skipped in the rendering list. This happens automatically and the - * culled state is refreshed every frame, for every camera. - * - * The origin of a Point Light is always 0.5 and it cannot be changed. - * - * Point Lights are a WebGL only feature and do not have a Canvas counterpart. - * @param x The horizontal position of this Point Light in the world. - * @param y The vertical position of this Point Light in the world. - * @param color The color of the Point Light, given as a hex value. Default 0xffffff. - * @param radius The radius of the Point Light. Default 128. - * @param intensity The intensity, or colr blend, of the Point Light. Default 1. - * @param attenuation The attenuation of the Point Light. This is the reduction of light from the center point. Default 0.1. - */ - pointlight(x: number, y: number, color?: number, radius?: number, intensity?: number, attenuation?: number): Phaser.GameObjects.PointLight; - - /** - * Creates a new Render Texture Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. - * - * A Render Texture is a special texture that allows any number of Game Objects to be drawn to it. You can take many complex objects and - * draw them all to this one texture, which can they be used as the texture for other Game Object's. It's a way to generate dynamic - * textures at run-time that are WebGL friendly and don't invoke expensive GPU uploads. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param width The width of the Render Texture. Default 32. - * @param height The height of the Render Texture. Default 32. - */ - renderTexture(x: number, y: number, width?: number, height?: number): Phaser.GameObjects.RenderTexture; - - /** - * Creates a new Rope Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Rope Game Object and WebGL support have been built into Phaser. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. - * @param points An array containing the vertices data for this Rope. If none is provided a simple quad is created. See `setPoints` to set this post-creation. - * @param horizontal Should the vertices of this Rope be aligned horizontally (`true`), or vertically (`false`)? Default true. - * @param colors An optional array containing the color data for this Rope. You should provide one color value per pair of vertices. - * @param alphas An optional array containing the alpha data for this Rope. You should provide one alpha value per pair of vertices. - */ - rope(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number, points?: Phaser.Types.Math.Vector2Like[], horizontal?: boolean, colors?: number[], alphas?: number[]): Phaser.GameObjects.Rope; - - /** - * Creates a new Shader Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Shader Game Object and WebGL support have been built into Phaser. - * @param key The key of the shader to use from the shader cache, or a BaseShader instance. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param width The width of the Game Object. Default 128. - * @param height The height of the Game Object. Default 128. - * @param textures Optional array of texture keys to bind to the iChannel0...3 uniforms. The textures must already exist in the Texture Manager. - * @param textureData Optional additional texture data. - */ - shader(key: string | Phaser.Display.BaseShader, x?: number, y?: number, width?: number, height?: number, textures?: string[], textureData?: object): Phaser.GameObjects.Shader; - - /** - * Creates a new Arc Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Arc Game Object has been built into Phaser. - * - * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports both fill and stroke colors. - * - * When it renders it displays an arc shape. You can control the start and end angles of the arc, - * as well as if the angles are winding clockwise or anti-clockwise. With the default settings - * it renders as a complete circle. By changing the angles you can create other arc shapes, - * such as half-circles. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param radius The radius of the arc. Default 128. - * @param startAngle The start angle of the arc, in degrees. Default 0. - * @param endAngle The end angle of the arc, in degrees. Default 360. - * @param anticlockwise The winding order of the start and end angles. Default false. - * @param fillColor The color the arc will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the arc will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. - */ - arc(x?: number, y?: number, radius?: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Arc; - - /** - * Creates a new Circle Shape Game Object and adds it to the Scene. - * - * A Circle is an Arc with no defined start and end angle, making it render as a complete circle. - * - * Note: This method will only be available if the Arc Game Object has been built into Phaser. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param radius The radius of the circle. Default 128. - * @param fillColor The color the circle will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the circle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. - */ - circle(x?: number, y?: number, radius?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Arc; - - /** - * Creates a new Curve Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Curve Game Object has been built into Phaser. - * - * The Curve Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports both fill and stroke colors. - * - * To render a Curve Shape you must first create a `Phaser.Curves.Curve` object, then pass it to - * the Curve Shape in the constructor. - * - * The Curve shape also has a `smoothness` property and corresponding `setSmoothness` method. - * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations - * that take place during construction. Increase and decrease the default value for smoother, or more - * jagged, shapes. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param curve The Curve object to use to create the Shape. - * @param fillColor The color the curve will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the curve will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. - */ - curve(x?: number, y?: number, curve?: Phaser.Curves.Curve, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Curve; - - /** - * Creates a new Ellipse Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Ellipse Game Object has been built into Phaser. - * - * The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports both fill and stroke colors. - * - * When it renders it displays an ellipse shape. You can control the width and height of the ellipse. - * If the width and height match it will render as a circle. If the width is less than the height, - * it will look more like an egg shape. - * - * The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method. - * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations - * that take place during construction. Increase and decrease the default value for smoother, or more - * jagged, shapes. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param width The width of the ellipse. An ellipse with equal width and height renders as a circle. Default 128. - * @param height The height of the ellipse. An ellipse with equal width and height renders as a circle. Default 128. - * @param fillColor The color the ellipse will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. - */ - ellipse(x?: number, y?: number, width?: number, height?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Ellipse; - - /** - * Creates a new Grid Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Grid Game Object has been built into Phaser. - * - * The Grid Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports only fill colors and cannot be stroked. - * - * A Grid Shape allows you to display a grid in your game, where you can control the size of the - * grid as well as the width and height of the grid cells. You can set a fill color for each grid - * cell as well as an alternate fill color. When the alternate fill color is set then the grid - * cells will alternate the fill colors as they render, creating a chess-board effect. You can - * also optionally have an outline fill color. If set, this draws lines between the grid cells - * in the given color. If you specify an outline color with an alpha of zero, then it will draw - * the cells spaced out, but without the lines between them. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param width The width of the grid. Default 128. - * @param height The height of the grid. Default 128. - * @param cellWidth The width of one cell in the grid. Default 32. - * @param cellHeight The height of one cell in the grid. Default 32. - * @param fillColor The color the grid cells will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. - * @param outlineFillColor The color of the lines between the grid cells. - * @param outlineFillAlpha The alpha of the lines between the grid cells. - */ - grid(x?: number, y?: number, width?: number, height?: number, cellWidth?: number, cellHeight?: number, fillColor?: number, fillAlpha?: number, outlineFillColor?: number, outlineFillAlpha?: number): Phaser.GameObjects.Grid; - - /** - * Creates a new IsoBox Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the IsoBox Game Object has been built into Phaser. - * - * The IsoBox Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports only fill colors and cannot be stroked. - * - * An IsoBox is an 'isometric' rectangle. Each face of it has a different fill color. You can set - * the color of the top, left and right faces of the rectangle respectively. You can also choose - * which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. - * - * You cannot view an IsoBox from under-neath, however you can change the 'angle' by setting - * the `projection` property. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param size The width of the iso box in pixels. The left and right faces will be exactly half this value. Default 48. - * @param height The height of the iso box. The left and right faces will be this tall. The overall height of the isobox will be this value plus half the `size` value. Default 32. - * @param fillTop The fill color of the top face of the iso box. Default 0xeeeeee. - * @param fillLeft The fill color of the left face of the iso box. Default 0x999999. - * @param fillRight The fill color of the right face of the iso box. Default 0xcccccc. - */ - isobox(x?: number, y?: number, size?: number, height?: number, fillTop?: number, fillLeft?: number, fillRight?: number): Phaser.GameObjects.IsoBox; - - /** - * Creates a new IsoTriangle Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the IsoTriangle Game Object has been built into Phaser. - * - * The IsoTriangle Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports only fill colors and cannot be stroked. - * - * An IsoTriangle is an 'isometric' triangle. Think of it like a pyramid. Each face has a different - * fill color. You can set the color of the top, left and right faces of the triangle respectively - * You can also choose which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. - * - * You cannot view an IsoTriangle from under-neath, however you can change the 'angle' by setting - * the `projection` property. The `reversed` property controls if the IsoTriangle is rendered upside - * down or not. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param size The width of the iso triangle in pixels. The left and right faces will be exactly half this value. Default 48. - * @param height The height of the iso triangle. The left and right faces will be this tall. The overall height of the iso triangle will be this value plus half the `size` value. Default 32. - * @param reversed Is the iso triangle upside down? Default false. - * @param fillTop The fill color of the top face of the iso triangle. Default 0xeeeeee. - * @param fillLeft The fill color of the left face of the iso triangle. Default 0x999999. - * @param fillRight The fill color of the right face of the iso triangle. Default 0xcccccc. - */ - isotriangle(x?: number, y?: number, size?: number, height?: number, reversed?: boolean, fillTop?: number, fillLeft?: number, fillRight?: number): Phaser.GameObjects.IsoTriangle; - - /** - * Creates a new Line Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Line Game Object has been built into Phaser. - * - * The Line Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports only stroke colors and cannot be filled. - * - * A Line Shape allows you to draw a line between two points in your game. You can control the - * stroke color and thickness of the line. In WebGL only you can also specify a different - * thickness for the start and end of the line, allowing you to render lines that taper-off. - * - * If you need to draw multiple lines in a sequence you may wish to use the Polygon Shape instead. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param x1 The horizontal position of the start of the line. Default 0. - * @param y1 The vertical position of the start of the line. Default 0. - * @param x2 The horizontal position of the end of the line. Default 128. - * @param y2 The vertical position of the end of the line. Default 0. - * @param strokeColor The color the line will be drawn in, i.e. 0xff0000 for red. - * @param strokeAlpha The alpha the line will be drawn in. You can also set the alpha of the overall Shape using its `alpha` property. - */ - line(x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, strokeColor?: number, strokeAlpha?: number): Phaser.GameObjects.Line; - - /** - * Creates a new Polygon Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Polygon Game Object has been built into Phaser. - * - * The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports both fill and stroke colors. - * - * The Polygon Shape is created by providing a list of points, which are then used to create an - * internal Polygon geometry object. The points can be set from a variety of formats: - * - * - An array of Point or Vector2 objects: `[new Phaser.Math.Vector2(x1, y1), ...]` - * - An array of objects with public x/y properties: `[obj1, obj2, ...]` - * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` - * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` - * - * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending - * on the coordinates of the points provided, the final shape may be rendered offset from its origin. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param points The points that make up the polygon. - * @param fillColor The color the polygon will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. - */ - polygon(x?: number, y?: number, points?: any, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Polygon; - - /** - * Creates a new Rectangle Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Rectangle Game Object has been built into Phaser. - * - * The Rectangle Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports both fill and stroke colors. - * - * You can change the size of the rectangle by changing the `width` and `height` properties. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param width The width of the rectangle. Default 128. - * @param height The height of the rectangle. Default 128. - * @param fillColor The color the rectangle will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the rectangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. - */ - rectangle(x?: number, y?: number, width?: number, height?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Rectangle; - - /** - * Creates a new Star Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Star Game Object has been built into Phaser. - * - * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports both fill and stroke colors. - * - * As the name implies, the Star shape will display a star in your game. You can control several - * aspects of it including the number of points that constitute the star. The default is 5. If - * you change it to 4 it will render as a diamond. If you increase them, you'll get a more spiky - * star shape. - * - * You can also control the inner and outer radius, which is how 'long' each point of the star is. - * Modify these values to create more interesting shapes. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param points The number of points on the star. Default 5. - * @param innerRadius The inner radius of the star. Default 32. - * @param outerRadius The outer radius of the star. Default 64. - * @param fillColor The color the star will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the star will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. - */ - star(x?: number, y?: number, points?: number, innerRadius?: number, outerRadius?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Star; - - /** - * Creates a new Triangle Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Triangle Game Object has been built into Phaser. - * - * The Triangle Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports both fill and stroke colors. - * - * The Triangle consists of 3 lines, joining up to form a triangular shape. You can control the - * position of each point of these lines. The triangle is always closed and cannot have an open - * face. If you require that, consider using a Polygon instead. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param x1 The horizontal position of the first point in the triangle. Default 0. - * @param y1 The vertical position of the first point in the triangle. Default 128. - * @param x2 The horizontal position of the second point in the triangle. Default 64. - * @param y2 The vertical position of the second point in the triangle. Default 0. - * @param x3 The horizontal position of the third point in the triangle. Default 128. - * @param y3 The vertical position of the third point in the triangle. Default 128. - * @param fillColor The color the triangle will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the triangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. - */ - triangle(x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Triangle; - - /** - * Creates a new Sprite Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Sprite Game Object has been built into Phaser. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. - */ - sprite(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.Sprite; - - /** - * Creates a new Text Game Object and adds it to the Scene. - * - * A Text Game Object. - * - * Text objects work by creating their own internal hidden Canvas and then renders text to it using - * the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered - * to your game during the render pass. - * - * Because it uses the Canvas API you can take advantage of all the features this offers, such as - * applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts - * loaded externally, such as Google or TypeKit Web fonts. - * - * You can only display fonts that are currently loaded and available to the browser: therefore fonts must - * be pre-loaded. Phaser does not do ths for you, so you will require the use of a 3rd party font loader, - * or have the fonts ready available in the CSS on the page in which your Phaser game resides. - * - * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts - * across mobile browsers. - * - * A note on performance: Every time the contents of a Text object changes, i.e. changing the text being - * displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the - * new texture to the GPU. This can be an expensive operation if used often, or with large quantities of - * Text objects in your game. If you run into performance issues you would be better off using Bitmap Text - * instead, as it benefits from batching and avoids expensive Canvas API calls. - * - * Note: This method will only be available if the Text Game Object has been built into Phaser. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param text The text this Text object will display. - * @param style The Text style configuration object. - */ - text(x: number, y: number, text: string | string[], style?: Phaser.Types.GameObjects.Text.TextStyle): Phaser.GameObjects.Text; - - /** - * Creates a new TileSprite Game Object and adds it to the Scene. - * - * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param width The width of the Game Object. If zero it will use the size of the texture frame. - * @param height The height of the Game Object. If zero it will use the size of the texture frame. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. - */ - tileSprite(x: number, y: number, width: number, height: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.TileSprite; - - /** - * Creates a new Video Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Video Game Object has been built into Phaser. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param key Optional key of the Video this Game Object will play, as stored in the Video Cache. - */ - video(x: number, y: number, key?: string): Phaser.GameObjects.Video; - - /** - * Creates a new Zone Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Zone Game Object has been built into Phaser. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param width The width of the Game Object. - * @param height The height of the Game Object. - */ - zone(x: number, y: number, width: number, height: number): Phaser.GameObjects.Zone; - - /** - * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. - * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing - * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map - * data. For an empty map, you should specify tileWidth, tileHeight, width & height. - * @param key The key in the Phaser cache that corresponds to the loaded tilemap data. - * @param tileWidth The width of a tile in pixels. Pass in `null` to leave as the - * default. Default 32. - * @param tileHeight The height of a tile in pixels. Pass in `null` to leave as the - * default. Default 32. - * @param width The width of the map in tiles. Pass in `null` to leave as the - * default. Default 10. - * @param height The height of the map in tiles. Pass in `null` to leave as the - * default. Default 10. - * @param data Instead of loading from the cache, you can also load directly from - * a 2D array of tile indexes. Pass in `null` for no data. - * @param insertNull Controls how empty tiles, tiles with an index of -1, in the - * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. Default false. - */ - tilemap(key?: string, tileWidth?: number, tileHeight?: number, width?: number, height?: number, data?: number[][], insertNull?: boolean): Phaser.Tilemaps.Tilemap; - - /** - * Creates a new Tween object. - * - * Note: This method will only be available if Tweens have been built into Phaser. - * @param config The Tween configuration. - */ - tween(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.Tween; - - } - - /** - * Calculates the Transform Matrix of the given Game Object and Camera, factoring in - * the parent matrix if provided. - * - * Note that the object this results contains _references_ to the Transform Matrices, - * not new instances of them. Therefore, you should use their values immediately, or - * copy them to your own matrix, as they will be replaced as soon as another Game - * Object is rendered. - * @param src The Game Object to calculate the transform matrix for. - * @param camera The camera being used to render the Game Object. - * @param parentMatrix The transform matrix of the parent container, if any. - */ - function GetCalcMatrix(src: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Types.GameObjects.GetCalcMatrixResults; - /** * A Graphics object is a way to draw primitive shapes to your game. Primitives include forms of geometry, such as * Rectangles, Circles, and Polygons. They also include lines, arcs and curves. When you initially create a Graphics @@ -19681,7 +19735,7 @@ declare namespace Phaser { /** * Returns all children in this Group that match the given criteria based on the `property` and `value` arguments. * - * For example: `getAll('visible', true)` would return only children that have their `visible` property set. + * For example: `getMatching('visible', true)` would return only children that have their `visible` property set. * * Optionally, you can specify a start and end index. For example if the Group has 100 elements, * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only @@ -21999,7 +22053,7 @@ declare namespace Phaser { * @param intensity The intensity, or colr blend, of the Point Light. Default 1. * @param attenuation The attenuation of the Point Light. This is the reduction of light from the center point. Default 0.1. */ - addPointlight(x: number, y: number, color?: number, radius?: number, intensity?: number, attenuation?: number): Phaser.GameObjects.PointLight; + addPointLight(x: number, y: number, color?: number, radius?: number, intensity?: number, attenuation?: number): Phaser.GameObjects.PointLight; /** * Enable the Lights Manager. @@ -26962,8 +27016,10 @@ declare namespace Phaser { * @param y The vertical position of this Game Object in the world. Default 0. * @param width The width of the Render Texture. Default 32. * @param height The height of the Render Texture. Default 32. + * @param key The texture key to make the RenderTexture from. + * @param frame The frame to make the RenderTexture from. */ - constructor(scene: Phaser.Scene, x?: number, y?: number, width?: number, height?: number); + constructor(scene: Phaser.Scene, x?: number, y?: number, width?: number, height?: number, key?: string, frame?: string); /** * A reference to either the Canvas or WebGL Renderer that the Game instance is using. @@ -30326,6 +30382,825 @@ declare namespace Phaser { } + /** + * The Shape Game Object is a base class for the various different shapes, such as the Arc, Star or Polygon. + * You cannot add a Shape directly to your Scene, it is meant as a base for your own custom Shape classes. + */ + class Shape extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + /** + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param type The internal type of the Shape. + * @param data The data of the source shape geometry, if any. + */ + constructor(scene: Phaser.Scene, type?: string, data?: any); + + /** + * The source Shape data. Typically a geometry object. + * You should not manipulate this directly. + */ + readonly geom: any; + + /** + * Holds the polygon path data for filled rendering. + */ + readonly pathData: number[]; + + /** + * Holds the earcut polygon path index data for filled rendering. + */ + readonly pathIndexes: number[]; + + /** + * The fill color used by this Shape. + */ + fillColor: number; + + /** + * The fill alpha value used by this Shape. + */ + fillAlpha: number; + + /** + * The stroke color used by this Shape. + */ + strokeColor: number; + + /** + * The stroke alpha value used by this Shape. + */ + strokeAlpha: number; + + /** + * The stroke line width used by this Shape. + */ + lineWidth: number; + + /** + * Controls if this Shape is filled or not. + * Note that some Shapes do not support being filled (such as Line shapes) + */ + isFilled: boolean; + + /** + * Controls if this Shape is stroked or not. + * Note that some Shapes do not support being stroked (such as Iso Box shapes) + */ + isStroked: boolean; + + /** + * Controls if this Shape path is closed during rendering when stroked. + * Note that some Shapes are always closed when stroked (such as Ellipse shapes) + */ + closePath: boolean; + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * Sets the fill color and alpha for this Shape. + * + * If you wish for the Shape to not be filled then call this method with no arguments, or just set `isFilled` to `false`. + * + * Note that some Shapes do not support fill colors, such as the Line shape. + * + * This call can be chained. + * @param color The color used to fill this shape. If not provided the Shape will not be filled. + * @param alpha The alpha value used when filling this shape, if a fill color is given. Default 1. + */ + setFillStyle(color?: number, alpha?: number): this; + + /** + * Sets the stroke color and alpha for this Shape. + * + * If you wish for the Shape to not be stroked then call this method with no arguments, or just set `isStroked` to `false`. + * + * Note that some Shapes do not support being stroked, such as the Iso Box shape. + * + * This call can be chained. + * @param lineWidth The width of line to stroke with. If not provided or undefined the Shape will not be stroked. + * @param color The color used to stroke this shape. If not provided the Shape will not be stroked. + * @param alpha The alpha value used when stroking this shape, if a stroke color is given. Default 1. + */ + setStrokeStyle(lineWidth?: number, color?: number, alpha?: number): this; + + /** + * Sets if this Shape path is closed during rendering when stroked. + * Note that some Shapes are always closed when stroked (such as Ellipse shapes) + * + * This call can be chained. + * @param value Set to `true` if the Shape should be closed when stroked, otherwise `false`. + */ + setClosePath(value: boolean): this; + + /** + * Sets the display size of this Shape. + * + * Calling this will adjust the scale. + * @param width The display width of this Shape. + * @param height The display height of this Shape. + */ + setDisplaySize(width: number, height: number): this; + + /** + * Internal destroy handler, called as part of the destroy process. + */ + protected preDestroy(): void; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * @param value The alpha value applied across the whole Game Object. Default 1. + */ + setAlpha(value?: number): this; + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: number): this; + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + */ + getCenter(output?: O): O; + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the left-center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getLeftCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the right-center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getRightCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. + */ + getBounds(output?: O): O; + + /** + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. + */ + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + + /** + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one. + * + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + * + * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Does this Game Object have any Post Pipelines set? + */ + hasPostPipeline: boolean; + + /** + * The WebGL Post FX Pipelines this Game Object uses for post-render effects. + * + * The pipelines are processed in the order in which they appear in this array. + * + * If you modify this array directly, be sure to set the + * `hasPostPipeline` property accordingly. + */ + postPipeline: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + + /** + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + */ + pipelineData: object; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * + * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + */ + initPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; + + /** + * Sets the main WebGL Pipeline of this Game Object. + * + * Also sets the `pipelineData` property, if the parameter is given. + * + * Both the pipeline and post pipelines share the same pipeline data object. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * @param pipelineData Optional pipeline data object that is _deep copied_ into the `pipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + */ + setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; + + /** + * Sets one, or more, Post Pipelines on this Game Object. + * + * Post Pipelines are invoked after this Game Object has rendered to its target and + * are commonly used for post-fx. + * + * The post pipelines are appended to the `postPipelines` array belonging to this + * Game Object. When the renderer processes this Game Object, it iterates through the post + * pipelines in the order in which they appear in the array. If you are stacking together + * multiple effects, be aware that the order is important. + * + * If you call this method multiple times, the new pipelines will be appended to any existing + * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. + * + * You can optionally also sets the `pipelineData` property, if the parameter is given. + * + * Both the pipeline and post pipelines share the pipeline data object together. + * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. + * @param pipelineData Optional pipeline data object that is _deep copied_ into the `pipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + */ + setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; + + /** + * Adds an entry to the `pipelineData` object belonging to this Game Object. + * + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * + * Both the pipeline and post pipelines share the pipeline data object together. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + */ + setPipelineData(key: string, value?: any): this; + + /** + * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. + * @param pipeline The string-based name of the pipeline, or a pipeline class. + */ + getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + * @param resetPostPipelines Reset all of the post pipelines? Default false. + * @param resetData Reset the `pipelineData` object to being an empty object? Default false. + */ + resetPipeline(resetPostPipelines?: boolean, resetData?: boolean): boolean; + + /** + * Resets the WebGL Post Pipelines of this Game Object. It does this by calling + * the `destroy` method on each post pipeline and then clearing the local array. + * @param resetData Reset the `pipelineData` object to being an empty object? Default false. + */ + resetPostPipeline(resetData?: boolean): void; + + /** + * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. + * + * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. + * @param pipeline The string-based name of the pipeline, or a pipeline class. + */ + removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#depth} instead. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: number; + + /** + * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object + * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. + * + * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this + * isn't the case, use the `scaleX` or `scaleY` properties instead. + */ + scale: number; + + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + + /** + * The angle of this Game Object as expressed in degrees. + * + * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left + * and -90 is up. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: number; + + /** + * The angle of this Game Object in radians. + * + * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left + * and -PI/2 is up. + * + * If you prefer to work in degrees, see the `angle` property instead. + */ + rotation: number; + + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + + /** + * Copies an object's coordinates to this Game Object's position. + * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. + */ + copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. + */ + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + + /** + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; + + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x: number, y?: number): this; + + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. + * + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Takes the given `x` and `y` coordinates and converts them into local space for this + * Game Object, taking into account parent and local transforms, and the Display Origin. + * + * The returned Vector2 contains the translated point in its properties. + * + * A Camera needs to be provided in order to handle modified scroll factors. If no + * camera is specified, it will use the `main` camera from the Scene to which this + * Game Object belongs. + * @param x The x position to translate. + * @param y The y position to translate. + * @param point A Vector2, or point-like object, to store the results in. + * @param camera The Camera which is being tested against. If not given will use the Scene default camera. + */ + getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + + /** + * Gets the sum total rotation of all of this Game Objects parent Containers. + * + * The returned value is in radians and will be zero if this Game Object has no parent container. + */ + getParentRotation(): number; + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + + } + /** * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling @@ -36909,825 +37784,6 @@ declare namespace Phaser { } - /** - * The Shape Game Object is a base class for the various different shapes, such as the Arc, Star or Polygon. - * You cannot add a Shape directly to your Scene, it is meant as a base for your own custom Shape classes. - */ - class Shape extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { - /** - * - * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param type The internal type of the Shape. - * @param data The data of the source shape geometry, if any. - */ - constructor(scene: Phaser.Scene, type?: string, data?: any); - - /** - * The source Shape data. Typically a geometry object. - * You should not manipulate this directly. - */ - readonly geom: any; - - /** - * Holds the polygon path data for filled rendering. - */ - readonly pathData: number[]; - - /** - * Holds the earcut polygon path index data for filled rendering. - */ - readonly pathIndexes: number[]; - - /** - * The fill color used by this Shape. - */ - fillColor: number; - - /** - * The fill alpha value used by this Shape. - */ - fillAlpha: number; - - /** - * The stroke color used by this Shape. - */ - strokeColor: number; - - /** - * The stroke alpha value used by this Shape. - */ - strokeAlpha: number; - - /** - * The stroke line width used by this Shape. - */ - lineWidth: number; - - /** - * Controls if this Shape is filled or not. - * Note that some Shapes do not support being filled (such as Line shapes) - */ - isFilled: boolean; - - /** - * Controls if this Shape is stroked or not. - * Note that some Shapes do not support being stroked (such as Iso Box shapes) - */ - isStroked: boolean; - - /** - * Controls if this Shape path is closed during rendering when stroked. - * Note that some Shapes are always closed when stroked (such as Ellipse shapes) - */ - closePath: boolean; - - /** - * The native (un-scaled) width of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayWidth` property. - */ - width: number; - - /** - * The native (un-scaled) height of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayHeight` property. - */ - height: number; - - /** - * Sets the fill color and alpha for this Shape. - * - * If you wish for the Shape to not be filled then call this method with no arguments, or just set `isFilled` to `false`. - * - * Note that some Shapes do not support fill colors, such as the Line shape. - * - * This call can be chained. - * @param color The color used to fill this shape. If not provided the Shape will not be filled. - * @param alpha The alpha value used when filling this shape, if a fill color is given. Default 1. - */ - setFillStyle(color?: number, alpha?: number): this; - - /** - * Sets the stroke color and alpha for this Shape. - * - * If you wish for the Shape to not be stroked then call this method with no arguments, or just set `isStroked` to `false`. - * - * Note that some Shapes do not support being stroked, such as the Iso Box shape. - * - * This call can be chained. - * @param lineWidth The width of line to stroke with. If not provided or undefined the Shape will not be stroked. - * @param color The color used to stroke this shape. If not provided the Shape will not be stroked. - * @param alpha The alpha value used when stroking this shape, if a stroke color is given. Default 1. - */ - setStrokeStyle(lineWidth?: number, color?: number, alpha?: number): this; - - /** - * Sets if this Shape path is closed during rendering when stroked. - * Note that some Shapes are always closed when stroked (such as Ellipse shapes) - * - * This call can be chained. - * @param value Set to `true` if the Shape should be closed when stroked, otherwise `false`. - */ - setClosePath(value: boolean): this; - - /** - * Sets the display size of this Shape. - * - * Calling this will adjust the scale. - * @param width The display width of this Shape. - * @param height The display height of this Shape. - */ - setDisplaySize(width: number, height: number): this; - - /** - * Internal destroy handler, called as part of the destroy process. - */ - protected preDestroy(): void; - - /** - * The displayed width of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. - */ - displayWidth: number; - - /** - * The displayed height of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. - */ - displayHeight: number; - - /** - * Clears all alpha values associated with this Game Object. - * - * Immediately sets the alpha levels back to 1 (fully opaque). - */ - clearAlpha(): this; - - /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * @param value The alpha value applied across the whole Game Object. Default 1. - */ - setAlpha(value?: number): this; - - /** - * The alpha value of the Game Object. - * - * This is a global value, impacting the entire Game Object, not just a region of it. - */ - alpha: number; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string or a CONST. - */ - setBlendMode(value: string | Phaser.BlendModes): this; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - */ - depth: number; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: number): this; - - /** - * Gets the center coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * @param output An object to store the values in. If not provided a new Vector2 will be created. - */ - getCenter(output?: O): O; - - /** - * Gets the top-left corner coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopLeft(output?: O, includeParent?: boolean): O; - - /** - * Gets the top-center coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the top-right corner coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopRight(output?: O, includeParent?: boolean): O; - - /** - * Gets the left-center coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getLeftCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the right-center coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getRightCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getBottomLeft(output?: O, includeParent?: boolean): O; - - /** - * Gets the bottom-center coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getBottomCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getBottomRight(output?: O, includeParent?: boolean): O; - - /** - * Gets the bounds of this Game Object, regardless of origin. - * The values are stored and returned in a Rectangle, or Rectangle-like, object. - * @param output An object to store the values in. If not provided a new Rectangle will be created. - */ - getBounds(output?: O): O; - - /** - * The Mask this Game Object is using during render. - */ - mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; - - /** - * Sets the mask that this Game Object will use to render with. - * - * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * If a mask is already set on this Game Object it will be immediately replaced. - * - * Masks are positioned in global space and are not relative to the Game Object to which they - * are applied. The reason for this is that multiple Game Objects can all share the same mask. - * - * Masks have no impact on physics or input detection. They are purely a rendering component - * that allows you to limit what is visible during the render pass. - * @param mask The mask this Game Object will use when rendering. - */ - setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; - - /** - * Clears the mask that this Game Object was using. - * @param destroyMask Destroy the mask before clearing it? Default false. - */ - clearMask(destroyMask?: boolean): this; - - /** - * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, - * including this one. - * - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - * - * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Does this Game Object have any Post Pipelines set? - */ - hasPostPipeline: boolean; - - /** - * The WebGL Post FX Pipelines this Game Object uses for post-render effects. - * - * The pipelines are processed in the order in which they appear in this array. - * - * If you modify this array directly, be sure to set the - * `hasPostPipeline` property accordingly. - */ - postPipeline: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; - - /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. - */ - pipelineData: object; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * - * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. - */ - initPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; - - /** - * Sets the main WebGL Pipeline of this Game Object. - * - * Also sets the `pipelineData` property, if the parameter is given. - * - * Both the pipeline and post pipelines share the same pipeline data object. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. - * @param pipelineData Optional pipeline data object that is _deep copied_ into the `pipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. - */ - setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; - - /** - * Sets one, or more, Post Pipelines on this Game Object. - * - * Post Pipelines are invoked after this Game Object has rendered to its target and - * are commonly used for post-fx. - * - * The post pipelines are appended to the `postPipelines` array belonging to this - * Game Object. When the renderer processes this Game Object, it iterates through the post - * pipelines in the order in which they appear in the array. If you are stacking together - * multiple effects, be aware that the order is important. - * - * If you call this method multiple times, the new pipelines will be appended to any existing - * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. - * - * You can optionally also sets the `pipelineData` property, if the parameter is given. - * - * Both the pipeline and post pipelines share the pipeline data object together. - * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. - * @param pipelineData Optional pipeline data object that is _deep copied_ into the `pipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. - */ - setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; - - /** - * Adds an entry to the `pipelineData` object belonging to this Game Object. - * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. - * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * - * Both the pipeline and post pipelines share the pipeline data object together. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. - */ - setPipelineData(key: string, value?: any): this; - - /** - * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. - * @param pipeline The string-based name of the pipeline, or a pipeline class. - */ - getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - * @param resetPostPipelines Reset all of the post pipelines? Default false. - * @param resetData Reset the `pipelineData` object to being an empty object? Default false. - */ - resetPipeline(resetPostPipelines?: boolean, resetData?: boolean): boolean; - - /** - * Resets the WebGL Post Pipelines of this Game Object. It does this by calling - * the `destroy` method on each post pipeline and then clearing the local array. - * @param resetData Reset the `pipelineData` object to being an empty object? Default false. - */ - resetPostPipeline(resetData?: boolean): void; - - /** - * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. - * - * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. - * @param pipeline The string-based name of the pipeline, or a pipeline class. - */ - removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#depth} instead. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: number; - - /** - * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object - * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. - * - * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this - * isn't the case, use the `scaleX` or `scaleY` properties instead. - */ - scale: number; - - /** - * The horizontal scale of this Game Object. - */ - scaleX: number; - - /** - * The vertical scale of this Game Object. - */ - scaleY: number; - - /** - * The angle of this Game Object as expressed in degrees. - * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left - * and -90 is up. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: number; - - /** - * The angle of this Game Object in radians. - * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left - * and -PI/2 is up. - * - * If you prefer to work in degrees, see the `angle` property instead. - */ - rotation: number; - - /** - * Sets the position of this Game Object. - * @param x The x position of this Game Object. Default 0. - * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. - * @param z The z position of this Game Object. Default 0. - * @param w The w position of this Game Object. Default 0. - */ - setPosition(x?: number, y?: number, z?: number, w?: number): this; - - /** - * Copies an object's coordinates to this Game Object's position. - * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. - */ - copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; - - /** - * Sets the position of this Game Object to be a random position within the confines of - * the given area. - * - * If no area is specified a random position between 0 x 0 and the game width x height is used instead. - * - * The position does not factor in the size of this Game Object, meaning that only the origin is - * guaranteed to be within the area. - * @param x The x position of the top-left of the random area. Default 0. - * @param y The y position of the top-left of the random area. Default 0. - * @param width The width of the random area. - * @param height The height of the random area. - */ - setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; - - /** - * Sets the rotation of this Game Object. - * @param radians The rotation of this Game Object, in radians. Default 0. - */ - setRotation(radians?: number): this; - - /** - * Sets the angle of this Game Object. - * @param degrees The rotation of this Game Object, in degrees. Default 0. - */ - setAngle(degrees?: number): this; - - /** - * Sets the scale of this Game Object. - * @param x The horizontal scale of this Game Object. - * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. - */ - setScale(x: number, y?: number): this; - - /** - * Sets the x position of this Game Object. - * @param value The x position of this Game Object. Default 0. - */ - setX(value?: number): this; - - /** - * Sets the y position of this Game Object. - * @param value The y position of this Game Object. Default 0. - */ - setY(value?: number): this; - - /** - * Sets the z position of this Game Object. - * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. - * @param value The z position of this Game Object. Default 0. - */ - setZ(value?: number): this; - - /** - * Sets the w position of this Game Object. - * @param value The w position of this Game Object. Default 0. - */ - setW(value?: number): this; - - /** - * Gets the local transform matrix for this Game Object. - * @param tempMatrix The matrix to populate with the values from this Game Object. - */ - getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; - - /** - * Gets the world transform matrix for this Game Object, factoring in any parent Containers. - * @param tempMatrix The matrix to populate with the values from this Game Object. - * @param parentMatrix A temporary matrix to hold parent values during the calculations. - */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; - - /** - * Takes the given `x` and `y` coordinates and converts them into local space for this - * Game Object, taking into account parent and local transforms, and the Display Origin. - * - * The returned Vector2 contains the translated point in its properties. - * - * A Camera needs to be provided in order to handle modified scroll factors. If no - * camera is specified, it will use the `main` camera from the Scene to which this - * Game Object belongs. - * @param x The x position to translate. - * @param y The y position to translate. - * @param point A Vector2, or point-like object, to store the results in. - * @param camera The Camera which is being tested against. If not given will use the Scene default camera. - */ - getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; - - /** - * Gets the sum total rotation of all of this Game Objects parent Containers. - * - * The returned value is in radians and will be zero if this Game Object has no parent container. - */ - getParentRotation(): number; - - /** - * The visible state of the Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - */ - visible: boolean; - - /** - * Sets the visibility of this Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * @param value The visible state of the Game Object. - */ - setVisible(value: boolean): this; - - } - /** * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling @@ -43272,55 +43328,6 @@ declare namespace Phaser { } - /** - * The Update List plugin. - * - * Update Lists belong to a Scene and maintain the list Game Objects to be updated every frame. - * - * Some or all of these Game Objects may also be part of the Scene's [Display List]{@link Phaser.GameObjects.DisplayList}, for Rendering. - */ - class UpdateList extends Phaser.Structs.ProcessQueue { - /** - * - * @param scene The Scene that the Update List belongs to. - */ - constructor(scene: Phaser.Scene); - - /** - * The Scene that the Update List belongs to. - */ - scene: Phaser.Scene; - - /** - * The Scene's Systems. - */ - systems: Phaser.Scenes.Systems; - - /** - * The update step. - * - * Pre-updates every active Game Object in the list. - * @param time The current timestamp. - * @param delta The delta time elapsed since the last frame. - */ - sceneUpdate(time: number, delta: number): void; - - /** - * The Scene that owns this plugin is shutting down. - * - * We need to kill and reset all internal properties as well as stop listening to Scene events. - */ - shutdown(): void; - - /** - * The Scene that owns this plugin is being destroyed. - * - * We need to shutdown and then kill off all external references. - */ - destroy(): void; - - } - /** * A Video Game Object. * @@ -47078,7 +47085,7 @@ declare namespace Phaser { /** * Calculates the vector projection of `pointA` onto the nonzero `pointB`. This is the - * orthogonal projection of `pointA` onto a straight line paralle to `pointB`. + * orthogonal projection of `pointA` onto a straight line parallel to `pointB`. * @param pointA Point A, to be projected onto Point B. * @param pointB Point B, to have Point A projected upon it. * @param out The Point object to store the position in. If not given, a new Point instance is created. @@ -48100,6 +48107,1343 @@ declare namespace Phaser { } namespace Input { + /** + * Creates a new Interactive Object. + * + * This is called automatically by the Input Manager when you enable a Game Object for input. + * + * The resulting Interactive Object is mapped to the Game Object's `input` property. + * @param gameObject The Game Object to which this Interactive Object is bound. + * @param hitArea The hit area for this Interactive Object. Typically a geometry shape, like a Rectangle or Circle. + * @param hitAreaCallback The 'contains' check callback that the hit area shape will use for all hit tests. + */ + function CreateInteractiveObject(gameObject: Phaser.GameObjects.GameObject, hitArea: any, hitAreaCallback: Phaser.Types.Input.HitAreaCallback): Phaser.Types.Input.InteractiveObject; + + /** + * Creates a new Pixel Perfect Handler function. + * + * Access via `InputPlugin.makePixelPerfect` rather than calling it directly. + * @param textureManager A reference to the Texture Manager. + * @param alphaTolerance The alpha level that the pixel should be above to be included as a successful interaction. + */ + function CreatePixelPerfectHandler(textureManager: Phaser.Textures.TextureManager, alphaTolerance: number): Function; + + /** + * The Input Manager is responsible for handling the pointer related systems in a single Phaser Game instance. + * + * Based on the Game Config it will create handlers for mouse and touch support. + * + * Keyboard and Gamepad are plugins, handled directly by the InputPlugin class. + * + * It then manages the events, pointer creation and general hit test related operations. + * + * You rarely need to interact with the Input Manager directly, and as such, all of its properties and methods + * should be considered private. Instead, you should use the Input Plugin, which is a Scene level system, responsible + * for dealing with all input events for a Scene. + */ + class InputManager { + /** + * + * @param game The Game instance that owns the Input Manager. + * @param config The Input Configuration object, as set in the Game Config. + */ + constructor(game: Phaser.Game, config: object); + + /** + * The Game instance that owns the Input Manager. + * A Game only maintains on instance of the Input Manager at any time. + */ + readonly game: Phaser.Game; + + /** + * A reference to the global Game Scale Manager. + * Used for all bounds checks and pointer scaling. + */ + scaleManager: Phaser.Scale.ScaleManager; + + /** + * The Canvas that is used for all DOM event input listeners. + */ + canvas: HTMLCanvasElement; + + /** + * The Game Configuration object, as set during the game boot. + */ + config: Phaser.Core.Config; + + /** + * If set, the Input Manager will run its update loop every frame. + */ + enabled: boolean; + + /** + * The Event Emitter instance that the Input Manager uses to emit events from. + */ + events: Phaser.Events.EventEmitter; + + /** + * Are any mouse or touch pointers currently over the game canvas? + * This is updated automatically by the canvas over and out handlers. + */ + readonly isOver: boolean; + + /** + * The default CSS cursor to be used when interacting with your game. + * + * See the `setDefaultCursor` method for more details. + */ + defaultCursor: string; + + /** + * A reference to the Keyboard Manager class, if enabled via the `input.keyboard` Game Config property. + */ + keyboard: Phaser.Input.Keyboard.KeyboardManager; + + /** + * A reference to the Mouse Manager class, if enabled via the `input.mouse` Game Config property. + */ + mouse: Phaser.Input.Mouse.MouseManager; + + /** + * A reference to the Touch Manager class, if enabled via the `input.touch` Game Config property. + */ + touch: Phaser.Input.Touch.TouchManager; + + /** + * An array of Pointers that have been added to the game. + * The first entry is reserved for the Mouse Pointer, the rest are Touch Pointers. + * + * By default there is 1 touch pointer enabled. If you need more use the `addPointer` method to start them, + * or set the `input.activePointers` property in the Game Config. + */ + pointers: Phaser.Input.Pointer[]; + + /** + * The number of touch objects activated and being processed each update. + * + * You can change this by either calling `addPointer` at run-time, or by + * setting the `input.activePointers` property in the Game Config. + */ + readonly pointersTotal: number; + + /** + * The mouse has its own unique Pointer object, which you can reference directly if making a _desktop specific game_. + * If you are supporting both desktop and touch devices then do not use this property, instead use `activePointer` + * which will always map to the most recently interacted pointer. + */ + mousePointer: Phaser.Input.Pointer; + + /** + * The most recently active Pointer object. + * + * If you've only 1 Pointer in your game then this will accurately be either the first finger touched, or the mouse. + * + * If your game doesn't need to support multi-touch then you can safely use this property in all of your game + * code and it will adapt to be either the mouse or the touch, based on device. + */ + activePointer: Phaser.Input.Pointer; + + /** + * If the top-most Scene in the Scene List receives an input it will stop input from + * propagating any lower down the scene list, i.e. if you have a UI Scene at the top + * and click something on it, that click will not then be passed down to any other + * Scene below. Disable this to have input events passed through all Scenes, all the time. + */ + globalTopOnly: boolean; + + /** + * The time this Input Manager was last updated. + * This value is populated by the Game Step each frame. + */ + readonly time: number; + + /** + * The Boot handler is called by Phaser.Game when it first starts up. + * The renderer is available by now. + */ + protected boot(): void; + + /** + * Tells the Input system to set a custom cursor. + * + * This cursor will be the default cursor used when interacting with the game canvas. + * + * If an Interactive Object also sets a custom cursor, this is the cursor that is reset after its use. + * + * Any valid CSS cursor value is allowed, including paths to image files, i.e.: + * + * ```javascript + * this.input.setDefaultCursor('url(assets/cursors/sword.cur), pointer'); + * ``` + * + * Please read about the differences between browsers when it comes to the file formats and sizes they support: + * + * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor + * https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_User_Interface/Using_URL_values_for_the_cursor_property + * + * It's up to you to pick a suitable cursor format that works across the range of browsers you need to support. + * @param cursor The CSS to be used when setting the default cursor. + */ + setDefaultCursor(cursor: string): void; + + /** + * Adds new Pointer objects to the Input Manager. + * + * By default Phaser creates 2 pointer objects: `mousePointer` and `pointer1`. + * + * You can create more either by calling this method, or by setting the `input.activePointers` property + * in the Game Config, up to a maximum of 10 pointers. + * + * The first 10 pointers are available via the `InputPlugin.pointerX` properties, once they have been added + * via this method. + * @param quantity The number of new Pointers to create. A maximum of 10 is allowed in total. Default 1. + */ + addPointer(quantity?: number): Phaser.Input.Pointer[]; + + /** + * Internal method that gets a list of all the active Input Plugins in the game + * and updates each of them in turn, in reverse order (top to bottom), to allow + * for DOM top-level event handling simulation. + * @param type The type of event to process. + * @param pointers An array of Pointers on which the event occurred. + */ + updateInputPlugins(type: number, pointers: Phaser.Input.Pointer[]): void; + + /** + * Performs a hit test using the given Pointer and camera, against an array of interactive Game Objects. + * + * The Game Objects are culled against the camera, and then the coordinates are translated into the local camera space + * and used to determine if they fall within the remaining Game Objects hit areas or not. + * + * If nothing is matched an empty array is returned. + * + * This method is called automatically by InputPlugin.hitTestPointer and doesn't usually need to be invoked directly. + * @param pointer The Pointer to test against. + * @param gameObjects An array of interactive Game Objects to check. + * @param camera The Camera which is being tested against. + * @param output An array to store the results in. If not given, a new empty array is created. + */ + hitTest(pointer: Phaser.Input.Pointer, gameObjects: any[], camera: Phaser.Cameras.Scene2D.Camera, output?: any[]): any[]; + + /** + * Checks if the given x and y coordinate are within the hit area of the Game Object. + * + * This method assumes that the coordinate values have already been translated into the space of the Game Object. + * + * If the coordinates are within the hit area they are set into the Game Objects Input `localX` and `localY` properties. + * @param gameObject The interactive Game Object to check against. + * @param x The translated x coordinate for the hit test. + * @param y The translated y coordinate for the hit test. + */ + pointWithinHitArea(gameObject: Phaser.GameObjects.GameObject, x: number, y: number): boolean; + + /** + * Checks if the given x and y coordinate are within the hit area of the Interactive Object. + * + * This method assumes that the coordinate values have already been translated into the space of the Interactive Object. + * + * If the coordinates are within the hit area they are set into the Interactive Objects Input `localX` and `localY` properties. + * @param object The Interactive Object to check against. + * @param x The translated x coordinate for the hit test. + * @param y The translated y coordinate for the hit test. + */ + pointWithinInteractiveObject(object: Phaser.Types.Input.InteractiveObject, x: number, y: number): boolean; + + /** + * Transforms the pageX and pageY values of a Pointer into the scaled coordinate space of the Input Manager. + * @param pointer The Pointer to transform the values for. + * @param pageX The Page X value. + * @param pageY The Page Y value. + * @param wasMove Are we transforming the Pointer from a move event, or an up / down event? + */ + transformPointer(pointer: Phaser.Input.Pointer, pageX: number, pageY: number, wasMove: boolean): void; + + /** + * Destroys the Input Manager and all of its systems. + * + * There is no way to recover from doing this. + */ + destroy(): void; + + } + + /** + * The Input Plugin belongs to a Scene and handles all input related events and operations for it. + * + * You can access it from within a Scene using `this.input`. + * + * It emits events directly. For example, you can do: + * + * ```javascript + * this.input.on('pointerdown', callback, context); + * ``` + * + * To listen for a pointer down event anywhere on the game canvas. + * + * Game Objects can be enabled for input by calling their `setInteractive` method. After which they + * will directly emit input events: + * + * ```javascript + * var sprite = this.add.sprite(x, y, texture); + * sprite.setInteractive(); + * sprite.on('pointerdown', callback, context); + * ``` + * + * There are lots of game configuration options available relating to input. + * See the [Input Config object]{@linkcode Phaser.Types.Core.InputConfig} for more details, including how to deal with Phaser + * listening for input events outside of the canvas, how to set a default number of pointers, input + * capture settings and more. + * + * Please also see the Input examples and tutorials for further information. + * + * **Incorrect input coordinates with Angular** + * + * If you are using Phaser within Angular, and use nglf or the router, to make the component in which the Phaser game resides + * change state (i.e. appear or disappear) then you'll need to notify the Scale Manager about this, as Angular will mess with + * the DOM in a way in which Phaser can't detect directly. Call `this.scale.updateBounds()` as part of your game init in order + * to refresh the canvas DOM bounds values, which Phaser uses for input point position calculations. + */ + class InputPlugin extends Phaser.Events.EventEmitter { + /** + * + * @param scene A reference to the Scene that this Input Plugin is responsible for. + */ + constructor(scene: Phaser.Scene); + + /** + * A reference to the Scene that this Input Plugin is responsible for. + */ + scene: Phaser.Scene; + + /** + * A reference to the Scene Systems class. + */ + systems: Phaser.Scenes.Systems; + + /** + * A reference to the Scene Systems Settings. + */ + settings: Phaser.Types.Scenes.SettingsObject; + + /** + * A reference to the Game Input Manager. + */ + manager: Phaser.Input.InputManager; + + /** + * If `true` this Input Plugin will process DOM input events. + */ + enabled: boolean; + + /** + * A reference to the Scene Display List. This property is set during the `boot` method. + */ + displayList: Phaser.GameObjects.DisplayList; + + /** + * A reference to the Scene Cameras Manager. This property is set during the `boot` method. + */ + cameras: Phaser.Cameras.Scene2D.CameraManager; + + /** + * A reference to the Mouse Manager. + * + * This property is only set if Mouse support has been enabled in your Game Configuration file. + * + * If you just wish to get access to the mouse pointer, use the `mousePointer` property instead. + */ + mouse: Phaser.Input.Mouse.MouseManager; + + /** + * When set to `true` (the default) the Input Plugin will emulate DOM behavior by only emitting events from + * the top-most Game Objects in the Display List. + * + * If set to `false` it will emit events from all Game Objects below a Pointer, not just the top one. + */ + topOnly: boolean; + + /** + * How often should the Pointers be checked? + * + * The value is a time, given in ms, and is the time that must have elapsed between game steps before + * the Pointers will be polled again. When a pointer is polled it runs a hit test to see which Game + * Objects are currently below it, or being interacted with it. + * + * Pointers will *always* be checked if they have been moved by the user, or press or released. + * + * This property only controls how often they will be polled if they have not been updated. + * You should set this if you want to have Game Objects constantly check against the pointers, even + * if the pointer didn't itself move. + * + * Set to 0 to poll constantly. Set to -1 to only poll on user movement. + */ + pollRate: number; + + /** + * The distance, in pixels, a pointer has to move while being held down, before it thinks it is being dragged. + */ + dragDistanceThreshold: number; + + /** + * The amount of time, in ms, a pointer has to be held down before it thinks it is dragging. + * + * The default polling rate is to poll only on move so once the time threshold is reached the + * drag event will not start until you move the mouse. If you want it to start immediately + * when the time threshold is reached, you must increase the polling rate by calling + * [setPollAlways]{@linkcode Phaser.Input.InputPlugin#setPollAlways} or + * [setPollRate]{@linkcode Phaser.Input.InputPlugin#setPollRate}. + */ + dragTimeThreshold: number; + + /** + * Checks to see if both this plugin and the Scene to which it belongs is active. + */ + isActive(): boolean; + + /** + * This is called automatically by the Input Manager. + * It emits events for plugins to listen to and also handles polling updates, if enabled. + * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + updatePoll(time: number, delta: number): boolean; + + /** + * Clears a Game Object so it no longer has an Interactive Object associated with it. + * The Game Object is then queued for removal from the Input Plugin on the next update. + * @param gameObject The Game Object that will have its Interactive Object removed. + * @param skipQueue Skip adding this Game Object into the removal queue? Default false. + */ + clear(gameObject: Phaser.GameObjects.GameObject, skipQueue?: boolean): Phaser.GameObjects.GameObject; + + /** + * Disables Input on a single Game Object. + * + * An input disabled Game Object still retains its Interactive Object component and can be re-enabled + * at any time, by passing it to `InputPlugin.enable`. + * @param gameObject The Game Object to have its input system disabled. + */ + disable(gameObject: Phaser.GameObjects.GameObject): void; + + /** + * Enable a Game Object for interaction. + * + * If the Game Object already has an Interactive Object component, it is enabled and returned. + * + * Otherwise, a new Interactive Object component is created and assigned to the Game Object's `input` property. + * + * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area + * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced + * input detection. + * + * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If + * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific + * shape for it to use. + * + * You can also provide an Input Configuration Object as the only argument to this method. + * @param gameObject The Game Object to be enabled for input. + * @param hitArea Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param hitAreaCallback The 'contains' function to invoke to check if the pointer is within the hit area. + * @param dropZone Is this Game Object a drop zone or not? Default false. + */ + enable(gameObject: Phaser.GameObjects.GameObject, hitArea?: Phaser.Types.Input.InputConfiguration | any, hitAreaCallback?: Phaser.Types.Input.HitAreaCallback, dropZone?: boolean): this; + + /** + * Takes the given Pointer and performs a hit test against it, to see which interactive Game Objects + * it is currently above. + * + * The hit test is performed against which-ever Camera the Pointer is over. If it is over multiple + * cameras, it starts checking the camera at the top of the camera list, and if nothing is found, iterates down the list. + * @param pointer The Pointer to check against the Game Objects. + */ + hitTestPointer(pointer: Phaser.Input.Pointer): Phaser.GameObjects.GameObject[]; + + /** + * Returns the drag state of the given Pointer for this Input Plugin. + * + * The state will be one of the following: + * + * 0 = Not dragging anything + * 1 = Primary button down and objects below, so collect a draglist + * 2 = Pointer being checked if meets drag criteria + * 3 = Pointer meets criteria, notify the draglist + * 4 = Pointer actively dragging the draglist and has moved + * 5 = Pointer actively dragging but has been released, notify draglist + * @param pointer The Pointer to get the drag state for. + */ + getDragState(pointer: Phaser.Input.Pointer): number; + + /** + * Sets the drag state of the given Pointer for this Input Plugin. + * + * The state must be one of the following values: + * + * 0 = Not dragging anything + * 1 = Primary button down and objects below, so collect a draglist + * 2 = Pointer being checked if meets drag criteria + * 3 = Pointer meets criteria, notify the draglist + * 4 = Pointer actively dragging the draglist and has moved + * 5 = Pointer actively dragging but has been released, notify draglist + * @param pointer The Pointer to set the drag state for. + * @param state The drag state value. An integer between 0 and 5. + */ + setDragState(pointer: Phaser.Input.Pointer, state: number): void; + + /** + * Sets the draggable state of the given array of Game Objects. + * + * They can either be set to be draggable, or can have their draggable state removed by passing `false`. + * + * A Game Object will not fire drag events unless it has been specifically enabled for drag. + * @param gameObjects An array of Game Objects to change the draggable state on. + * @param value Set to `true` if the Game Objects should be made draggable, `false` if they should be unset. Default true. + */ + setDraggable(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], value?: boolean): this; + + /** + * Creates a function that can be passed to `setInteractive`, `enable` or `setHitArea` that will handle + * pixel-perfect input detection on an Image or Sprite based Game Object, or any custom class that extends them. + * + * The following will create a sprite that is clickable on any pixel that has an alpha value >= 1. + * + * ```javascript + * this.add.sprite(x, y, key).setInteractive(this.input.makePixelPerfect()); + * ``` + * + * The following will create a sprite that is clickable on any pixel that has an alpha value >= 150. + * + * ```javascript + * this.add.sprite(x, y, key).setInteractive(this.input.makePixelPerfect(150)); + * ``` + * + * Once you have made an Interactive Object pixel perfect it impacts all input related events for it: down, up, + * dragstart, drag, etc. + * + * As a pointer interacts with the Game Object it will constantly poll the texture, extracting a single pixel from + * the given coordinates and checking its color values. This is an expensive process, so should only be enabled on + * Game Objects that really need it. + * + * You cannot make non-texture based Game Objects pixel perfect. So this will not work on Graphics, BitmapText, + * Render Textures, Text, Tilemaps, Containers or Particles. + * @param alphaTolerance The alpha level that the pixel should be above to be included as a successful interaction. Default 1. + */ + makePixelPerfect(alphaTolerance?: number): Function; + + /** + * Sets the hit area for the given array of Game Objects. + * + * A hit area is typically one of the geometric shapes Phaser provides, such as a `Phaser.Geom.Rectangle` + * or `Phaser.Geom.Circle`. However, it can be any object as long as it works with the provided callback. + * + * If no hit area is provided a Rectangle is created based on the size of the Game Object, if possible + * to calculate. + * + * The hit area callback is the function that takes an `x` and `y` coordinate and returns a boolean if + * those values fall within the area of the shape or not. All of the Phaser geometry objects provide this, + * such as `Phaser.Geom.Rectangle.Contains`. + * @param gameObjects An array of Game Objects to set the hit area on. + * @param hitArea Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param hitAreaCallback The 'contains' function to invoke to check if the pointer is within the hit area. + */ + setHitArea(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], hitArea?: Phaser.Types.Input.InputConfiguration | any, hitAreaCallback?: Phaser.Types.Input.HitAreaCallback): this; + + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Circle` shape, using + * the given coordinates and radius to control its position and size. + * @param gameObjects An array of Game Objects to set as having a circle hit area. + * @param x The center of the circle. + * @param y The center of the circle. + * @param radius The radius of the circle. + * @param callback The hit area callback. If undefined it uses Circle.Contains. + */ + setHitAreaCircle(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], x: number, y: number, radius: number, callback?: Phaser.Types.Input.HitAreaCallback): this; + + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Ellipse` shape, using + * the given coordinates and dimensions to control its position and size. + * @param gameObjects An array of Game Objects to set as having an ellipse hit area. + * @param x The center of the ellipse. + * @param y The center of the ellipse. + * @param width The width of the ellipse. + * @param height The height of the ellipse. + * @param callback The hit area callback. If undefined it uses Ellipse.Contains. + */ + setHitAreaEllipse(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], x: number, y: number, width: number, height: number, callback?: Phaser.Types.Input.HitAreaCallback): this; + + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Rectangle` shape, using + * the Game Objects texture frame to define the position and size of the hit area. + * @param gameObjects An array of Game Objects to set as having an ellipse hit area. + * @param callback The hit area callback. If undefined it uses Rectangle.Contains. + */ + setHitAreaFromTexture(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], callback?: Phaser.Types.Input.HitAreaCallback): this; + + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Rectangle` shape, using + * the given coordinates and dimensions to control its position and size. + * @param gameObjects An array of Game Objects to set as having a rectangular hit area. + * @param x The top-left of the rectangle. + * @param y The top-left of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. + * @param callback The hit area callback. If undefined it uses Rectangle.Contains. + */ + setHitAreaRectangle(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], x: number, y: number, width: number, height: number, callback?: Phaser.Types.Input.HitAreaCallback): this; + + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Triangle` shape, using + * the given coordinates to control the position of its points. + * @param gameObjects An array of Game Objects to set as having a triangular hit area. + * @param x1 The x coordinate of the first point of the triangle. + * @param y1 The y coordinate of the first point of the triangle. + * @param x2 The x coordinate of the second point of the triangle. + * @param y2 The y coordinate of the second point of the triangle. + * @param x3 The x coordinate of the third point of the triangle. + * @param y3 The y coordinate of the third point of the triangle. + * @param callback The hit area callback. If undefined it uses Triangle.Contains. + */ + setHitAreaTriangle(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, callback?: Phaser.Types.Input.HitAreaCallback): this; + + /** + * Creates an Input Debug Shape for the given Game Object. + * + * The Game Object must have _already_ been enabled for input prior to calling this method. + * + * This is intended to assist you during development and debugging. + * + * Debug Shapes can only be created for Game Objects that are using standard Phaser Geometry for input, + * including: Circle, Ellipse, Line, Polygon, Rectangle and Triangle. + * + * Game Objects that are using their automatic hit areas are using Rectangles by default, so will also work. + * + * The Debug Shape is created and added to the display list and is then kept in sync with the Game Object + * it is connected with. Should you need to modify it yourself, such as to hide it, you can access it via + * the Game Object property: `GameObject.input.hitAreaDebug`. + * + * Calling this method on a Game Object that already has a Debug Shape will first destroy the old shape, + * before creating a new one. If you wish to remove the Debug Shape entirely, you should call the + * method `InputPlugin.removeDebug`. + * + * Note that the debug shape will only show the outline of the input area. If the input test is using a + * pixel perfect check, for example, then this is not displayed. If you are using a custom shape, that + * doesn't extend one of the base Phaser Geometry objects, as your hit area, then this method will not + * work. + * @param gameObject The Game Object to create the input debug shape for. + * @param color The outline color of the debug shape. Default 0x00ff00. + */ + enableDebug(gameObject: Phaser.GameObjects.GameObject, color?: number): this; + + /** + * Removes an Input Debug Shape from the given Game Object. + * + * The shape is destroyed immediately and the `hitAreaDebug` property is set to `null`. + * @param gameObject The Game Object to remove the input debug shape from. + */ + removeDebug(gameObject: Phaser.GameObjects.GameObject): this; + + /** + * Sets the Pointers to always poll. + * + * When a pointer is polled it runs a hit test to see which Game Objects are currently below it, + * or being interacted with it, regardless if the Pointer has actually moved or not. + * + * You should enable this if you want objects in your game to fire over / out events, and the objects + * are constantly moving, but the pointer may not have. Polling every frame has additional computation + * costs, especially if there are a large number of interactive objects in your game. + */ + setPollAlways(): this; + + /** + * Sets the Pointers to only poll when they are moved or updated. + * + * When a pointer is polled it runs a hit test to see which Game Objects are currently below it, + * or being interacted with it. + */ + setPollOnMove(): this; + + /** + * Sets the poll rate value. This is the amount of time that should have elapsed before a pointer + * will be polled again. See the `setPollAlways` and `setPollOnMove` methods. + * @param value The amount of time, in ms, that should elapsed before re-polling the pointers. + */ + setPollRate(value: number): this; + + /** + * When set to `true` the global Input Manager will emulate DOM behavior by only emitting events from + * the top-most Scene in the Scene List. By default, if a Scene receives an input event it will then stop the event + * from flowing down to any Scenes below it in the Scene list. To disable this behavior call this method with `false`. + * @param value Set to `true` to stop processing input events on the Scene that receives it, or `false` to let the event continue down the Scene list. + */ + setGlobalTopOnly(value: boolean): this; + + /** + * When set to `true` this Input Plugin will emulate DOM behavior by only emitting events from + * the top-most Game Objects in the Display List. + * + * If set to `false` it will emit events from all Game Objects below a Pointer, not just the top one. + * @param value `true` to only include the top-most Game Object, or `false` to include all Game Objects in a hit test. + */ + setTopOnly(value: boolean): this; + + /** + * Given an array of Game Objects and a Pointer, sort the array and return it, + * so that the objects are in render order with the lowest at the bottom. + * @param gameObjects An array of Game Objects to be sorted. + * @param pointer The Pointer to check against the Game Objects. + */ + sortGameObjects(gameObjects: Phaser.GameObjects.GameObject[], pointer: Phaser.Input.Pointer): Phaser.GameObjects.GameObject[]; + + /** + * Given an array of Drop Zone Game Objects, sort the array and return it, + * so that the objects are in depth index order with the lowest at the bottom. + * @param gameObjects An array of Game Objects to be sorted. + */ + sortDropZones(gameObjects: Phaser.GameObjects.GameObject[]): Phaser.GameObjects.GameObject[]; + + /** + * This method should be called from within an input event handler, such as `pointerdown`. + * + * When called, it stops the Input Manager from allowing _this specific event_ to be processed by any other Scene + * not yet handled in the scene list. + */ + stopPropagation(): this; + + /** + * Adds new Pointer objects to the Input Manager. + * + * By default Phaser creates 2 pointer objects: `mousePointer` and `pointer1`. + * + * You can create more either by calling this method, or by setting the `input.activePointers` property + * in the Game Config, up to a maximum of 10 pointers. + * + * The first 10 pointers are available via the `InputPlugin.pointerX` properties, once they have been added + * via this method. + * @param quantity The number of new Pointers to create. A maximum of 10 is allowed in total. Default 1. + */ + addPointer(quantity?: number): Phaser.Input.Pointer[]; + + /** + * Tells the Input system to set a custom cursor. + * + * This cursor will be the default cursor used when interacting with the game canvas. + * + * If an Interactive Object also sets a custom cursor, this is the cursor that is reset after its use. + * + * Any valid CSS cursor value is allowed, including paths to image files, i.e.: + * + * ```javascript + * this.input.setDefaultCursor('url(assets/cursors/sword.cur), pointer'); + * ``` + * + * Please read about the differences between browsers when it comes to the file formats and sizes they support: + * + * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor + * https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_User_Interface/Using_URL_values_for_the_cursor_property + * + * It's up to you to pick a suitable cursor format that works across the range of browsers you need to support. + * @param cursor The CSS to be used when setting the default cursor. + */ + setDefaultCursor(cursor: string): this; + + /** + * The x coordinates of the ActivePointer based on the first camera in the camera list. + * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. + */ + readonly x: number; + + /** + * The y coordinates of the ActivePointer based on the first camera in the camera list. + * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. + */ + readonly y: number; + + /** + * Are any mouse or touch pointers currently over the game canvas? + */ + readonly isOver: boolean; + + /** + * The mouse has its own unique Pointer object, which you can reference directly if making a _desktop specific game_. + * If you are supporting both desktop and touch devices then do not use this property, instead use `activePointer` + * which will always map to the most recently interacted pointer. + */ + readonly mousePointer: Phaser.Input.Pointer; + + /** + * The current active input Pointer. + */ + readonly activePointer: Phaser.Input.Pointer; + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + */ + readonly pointer1: Phaser.Input.Pointer; + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + */ + readonly pointer2: Phaser.Input.Pointer; + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + */ + readonly pointer3: Phaser.Input.Pointer; + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + */ + readonly pointer4: Phaser.Input.Pointer; + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + */ + readonly pointer5: Phaser.Input.Pointer; + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + */ + readonly pointer6: Phaser.Input.Pointer; + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + */ + readonly pointer7: Phaser.Input.Pointer; + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + */ + readonly pointer8: Phaser.Input.Pointer; + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + */ + readonly pointer9: Phaser.Input.Pointer; + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + */ + readonly pointer10: Phaser.Input.Pointer; + + /** + * An instance of the Gamepad Plugin class, if enabled via the `input.gamepad` Scene or Game Config property. + * Use this to create access Gamepads connected to the browser and respond to gamepad buttons. + */ + gamepad: Phaser.Input.Gamepad.GamepadPlugin; + + /** + * An instance of the Keyboard Plugin class, if enabled via the `input.keyboard` Scene or Game Config property. + * Use this to create Key objects and listen for keyboard specific events. + */ + keyboard: Phaser.Input.Keyboard.KeyboardPlugin; + + } + + namespace InputPluginCache { + /** + * Static method called directly by the Core internal Plugins. + * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) + * Plugin is the object to instantiate to create the plugin + * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) + * @param key A reference used to get this plugin from the plugin cache. + * @param plugin The plugin to be stored. Should be the core object, not instantiated. + * @param mapping If this plugin is to be injected into the Input Plugin, this is the property key used. + * @param settingsKey The key in the Scene Settings to check to see if this plugin should install or not. + * @param configKey The key in the Game Config to check to see if this plugin should install or not. + */ + function register(key: string, plugin: Function, mapping: string, settingsKey: string, configKey: string): void; + + /** + * Returns the input plugin object from the cache based on the given key. + * @param key The key of the input plugin to get. + */ + function getPlugin(key: string): Phaser.Types.Input.InputPluginContainer; + + /** + * Installs all of the registered Input Plugins into the given target. + * @param target The target InputPlugin to install the plugins into. + */ + function install(target: Phaser.Input.InputPlugin): void; + + /** + * Removes an input plugin based on the given key. + * @param key The key of the input plugin to remove. + */ + function remove(key: string): void; + + } + + /** + * A Pointer object encapsulates both mouse and touch input within Phaser. + * + * By default, Phaser will create 2 pointers for your game to use. If you require more, i.e. for a multi-touch + * game, then use the `InputPlugin.addPointer` method to do so, rather than instantiating this class directly, + * otherwise it won't be managed by the input system. + * + * You can reference the current active pointer via `InputPlugin.activePointer`. You can also use the properties + * `InputPlugin.pointer1` through to `pointer10`, for each pointer you have enabled in your game. + * + * The properties of this object are set by the Input Plugin during processing. This object is then sent in all + * input related events that the Input Plugin emits, so you can reference properties from it directly in your + * callbacks. + */ + class Pointer { + /** + * + * @param manager A reference to the Input Manager. + * @param id The internal ID of this Pointer. + */ + constructor(manager: Phaser.Input.InputManager, id: number); + + /** + * A reference to the Input Manager. + */ + manager: Phaser.Input.InputManager; + + /** + * The internal ID of this Pointer. + */ + readonly id: number; + + /** + * The most recent native DOM Event this Pointer has processed. + */ + event: TouchEvent | MouseEvent; + + /** + * The DOM element the Pointer was pressed down on, taken from the DOM event. + * In a default set-up this will be the Canvas that Phaser is rendering to, or the Window element. + */ + readonly downElement: any; + + /** + * The DOM element the Pointer was released on, taken from the DOM event. + * In a default set-up this will be the Canvas that Phaser is rendering to, or the Window element. + */ + readonly upElement: any; + + /** + * The camera the Pointer interacted with during its last update. + * + * A Pointer can only ever interact with one camera at once, which will be the top-most camera + * in the list should multiple cameras be positioned on-top of each other. + */ + camera: Phaser.Cameras.Scene2D.Camera; + + /** + * A read-only property that indicates which button was pressed, or released, on the pointer + * during the most recent event. It is only set during `up` and `down` events. + * + * On Touch devices the value is always 0. + * + * Users may change the configuration of buttons on their pointing device so that if an event's button property + * is zero, it may not have been caused by the button that is physically left–most on the pointing device; + * however, it should behave as if the left button was clicked in the standard button layout. + */ + readonly button: number; + + /** + * 0: No button or un-initialized + * 1: Left button + * 2: Right button + * 4: Wheel button or middle button + * 8: 4th button (typically the "Browser Back" button) + * 16: 5th button (typically the "Browser Forward" button) + * + * For a mouse configured for left-handed use, the button actions are reversed. + * In this case, the values are read from right to left. + */ + buttons: number; + + /** + * The position of the Pointer in screen space. + */ + readonly position: Phaser.Math.Vector2; + + /** + * The previous position of the Pointer in screen space. + * + * The old x and y values are stored in here during the InputManager.transformPointer call. + * + * Use the properties `velocity`, `angle` and `distance` to create your own gesture recognition. + */ + readonly prevPosition: Phaser.Math.Vector2; + + /** + * The current velocity of the Pointer, based on its current and previous positions. + * + * This value is smoothed out each frame, according to the `motionFactor` property. + * + * This property is updated whenever the Pointer moves, regardless of any button states. In other words, + * it changes based on movement alone - a button doesn't have to be pressed first. + */ + readonly velocity: Phaser.Math.Vector2; + + /** + * The current angle the Pointer is moving, in radians, based on its previous and current position. + * + * The angle is based on the old position facing to the current position. + * + * This property is updated whenever the Pointer moves, regardless of any button states. In other words, + * it changes based on movement alone - a button doesn't have to be pressed first. + */ + readonly angle: number; + + /** + * The distance the Pointer has moved, based on its previous and current position. + * + * This value is smoothed out each frame, according to the `motionFactor` property. + * + * This property is updated whenever the Pointer moves, regardless of any button states. In other words, + * it changes based on movement alone - a button doesn't have to be pressed first. + * + * If you need the total distance travelled since the primary buttons was pressed down, + * then use the `Pointer.getDistance` method. + */ + readonly distance: number; + + /** + * The smoothing factor to apply to the Pointer position. + * + * Due to their nature, pointer positions are inherently noisy. While this is fine for lots of games, if you need cleaner positions + * then you can set this value to apply an automatic smoothing to the positions as they are recorded. + * + * The default value of zero means 'no smoothing'. + * Set to a small value, such as 0.2, to apply an average level of smoothing between positions. You can do this by changing this + * value directly, or by setting the `input.smoothFactor` property in the Game Config. + * + * Positions are only smoothed when the pointer moves. If the primary button on this Pointer enters an Up or Down state, then the position + * is always precise, and not smoothed. + */ + smoothFactor: number; + + /** + * The factor applied to the motion smoothing each frame. + * + * This value is passed to the Smooth Step Interpolation that is used to calculate the velocity, + * angle and distance of the Pointer. It's applied every frame, until the midPoint reaches the current + * position of the Pointer. 0.2 provides a good average but can be increased if you need a + * quicker update and are working in a high performance environment. Never set this value to + * zero. + */ + motionFactor: number; + + /** + * The x position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. + * + * If you wish to use this value _outside_ of an input event handler then you should update it first by calling + * the `Pointer.updateWorldPoint` method. + */ + worldX: number; + + /** + * The y position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. + * + * If you wish to use this value _outside_ of an input event handler then you should update it first by calling + * the `Pointer.updateWorldPoint` method. + */ + worldY: number; + + /** + * Time when this Pointer was most recently moved (regardless of the state of its buttons, if any) + */ + moveTime: number; + + /** + * X coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. + */ + downX: number; + + /** + * Y coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. + */ + downY: number; + + /** + * The Event timestamp when the first button, or Touch input, was pressed. Used for dragging objects. + */ + downTime: number; + + /** + * X coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. + */ + upX: number; + + /** + * Y coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. + */ + upY: number; + + /** + * The Event timestamp when the final button, or Touch input, was released. Used for dragging objects. + */ + upTime: number; + + /** + * Is the primary button down? (usually button 0, the left mouse button) + */ + primaryDown: boolean; + + /** + * Is _any_ button on this pointer considered as being down? + */ + isDown: boolean; + + /** + * Did the previous input event come from a Touch input (true) or Mouse? (false) + */ + wasTouch: boolean; + + /** + * Did this Pointer get canceled by a touchcancel event? + * + * Note: "canceled" is the American-English spelling of "cancelled". Please don't submit PRs correcting it! + */ + wasCanceled: boolean; + + /** + * If the mouse is locked, the horizontal relative movement of the Pointer in pixels since last frame. + */ + movementX: number; + + /** + * If the mouse is locked, the vertical relative movement of the Pointer in pixels since last frame. + */ + movementY: number; + + /** + * The identifier property of the Pointer as set by the DOM event when this Pointer is started. + */ + identifier: number; + + /** + * The pointerId property of the Pointer as set by the DOM event when this Pointer is started. + * The browser can and will recycle this value. + */ + pointerId: number; + + /** + * An active Pointer is one that is currently pressed down on the display. + * A Mouse is always considered as active. + */ + active: boolean; + + /** + * Is this pointer Pointer Locked? + * + * Only a mouse pointer can be locked and it only becomes locked when requested via + * the browsers Pointer Lock API. + * + * You can request this by calling the `this.input.mouse.requestPointerLock()` method from + * a `pointerdown` or `pointerup` event handler. + */ + readonly locked: boolean; + + /** + * The horizontal scroll amount that occurred due to the user moving a mouse wheel or similar input device. + */ + deltaX: number; + + /** + * The vertical scroll amount that occurred due to the user moving a mouse wheel or similar input device. + * This value will typically be less than 0 if the user scrolls up and greater than zero if scrolling down. + */ + deltaY: number; + + /** + * The z-axis scroll amount that occurred due to the user moving a mouse wheel or similar input device. + */ + deltaZ: number; + + /** + * Takes a Camera and updates this Pointer's `worldX` and `worldY` values so they are + * the result of a translation through the given Camera. + * + * Note that the values will be automatically replaced the moment the Pointer is + * updated by an input event, such as a mouse move, so should be used immediately. + * @param camera The Camera which is being tested against. + */ + updateWorldPoint(camera: Phaser.Cameras.Scene2D.Camera): this; + + /** + * Takes a Camera and returns a Vector2 containing the translated position of this Pointer + * within that Camera. This can be used to convert this Pointers position into camera space. + * @param camera The Camera to use for the translation. + * @param output A Vector2-like object in which to store the translated position. + */ + positionToCamera(camera: Phaser.Cameras.Scene2D.Camera, output?: Phaser.Math.Vector2 | object): Phaser.Math.Vector2 | object; + + /** + * Checks to see if any buttons are being held down on this Pointer. + */ + noButtonDown(): boolean; + + /** + * Checks to see if the left button is being held down on this Pointer. + */ + leftButtonDown(): boolean; + + /** + * Checks to see if the right button is being held down on this Pointer. + */ + rightButtonDown(): boolean; + + /** + * Checks to see if the middle button is being held down on this Pointer. + */ + middleButtonDown(): boolean; + + /** + * Checks to see if the back button is being held down on this Pointer. + */ + backButtonDown(): boolean; + + /** + * Checks to see if the forward button is being held down on this Pointer. + */ + forwardButtonDown(): boolean; + + /** + * Checks to see if the left button was just released on this Pointer. + */ + leftButtonReleased(): boolean; + + /** + * Checks to see if the right button was just released on this Pointer. + */ + rightButtonReleased(): boolean; + + /** + * Checks to see if the middle button was just released on this Pointer. + */ + middleButtonReleased(): boolean; + + /** + * Checks to see if the back button was just released on this Pointer. + */ + backButtonReleased(): boolean; + + /** + * Checks to see if the forward button was just released on this Pointer. + */ + forwardButtonReleased(): boolean; + + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * distance between the Pointer's `downX` and `downY` values and the current position. + * + * If no button is held down, it will return the last recorded distance, based on where + * the Pointer was when the button was released. + * + * If you wish to get the distance being travelled currently, based on the velocity of the Pointer, + * then see the `Pointer.distance` property. + */ + getDistance(): number; + + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * horizontal distance between the Pointer's `downX` and `downY` values and the current position. + * + * If no button is held down, it will return the last recorded horizontal distance, based on where + * the Pointer was when the button was released. + */ + getDistanceX(): number; + + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * vertical distance between the Pointer's `downX` and `downY` values and the current position. + * + * If no button is held down, it will return the last recorded vertical distance, based on where + * the Pointer was when the button was released. + */ + getDistanceY(): number; + + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * duration since the button was pressed down. + * + * If no button is held down, it will return the last recorded duration, based on the time + * the last button on the Pointer was released. + */ + getDuration(): number; + + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * angle between the Pointer's `downX` and `downY` values and the current position. + * + * If no button is held down, it will return the last recorded angle, based on where + * the Pointer was when the button was released. + * + * The angle is based on the old position facing to the current position. + * + * If you wish to get the current angle, based on the velocity of the Pointer, then + * see the `Pointer.angle` property. + */ + getAngle(): number; + + /** + * Takes the previous and current Pointer positions and then generates an array of interpolated values between + * the two. The array will be populated up to the size of the `steps` argument. + * + * ```javaScript + * var points = pointer.getInterpolatedPosition(4); + * + * // points[0] = { x: 0, y: 0 } + * // points[1] = { x: 2, y: 1 } + * // points[2] = { x: 3, y: 2 } + * // points[3] = { x: 6, y: 3 } + * ``` + * + * Use this if you need to get smoothed values between the previous and current pointer positions. DOM pointer + * events can often fire faster than the main browser loop, and this will help you avoid janky movement + * especially if you have an object following a Pointer. + * + * Note that if you provide an output array it will only be populated up to the number of steps provided. + * It will not clear any previous data that may have existed beyond the range of the steps count. + * + * Internally it uses the Smooth Step interpolation calculation. + * @param steps The number of interpolation steps to use. Default 10. + * @param out An array to store the results in. If not provided a new one will be created. + */ + getInterpolatedPosition(steps?: number, out?: any[]): any[]; + + /** + * Destroys this Pointer instance and resets its external references. + */ + destroy(): void; + + /** + * The x position of this Pointer. + * The value is in screen space. + * See `worldX` to get a camera converted position. + */ + x: number; + + /** + * The y position of this Pointer. + * The value is in screen space. + * See `worldY` to get a camera converted position. + */ + y: number; + + /** + * Time when this Pointer was most recently updated by a DOM Event. + * This comes directly from the `event.timeStamp` property. + * If no event has yet taken place, it will return zero. + */ + readonly time: number; + + } + /** * The mouse pointer is being held down. */ @@ -48145,27 +49489,6 @@ declare namespace Phaser { */ var MOUSE_WHEEL: number; - /** - * Creates a new Interactive Object. - * - * This is called automatically by the Input Manager when you enable a Game Object for input. - * - * The resulting Interactive Object is mapped to the Game Object's `input` property. - * @param gameObject The Game Object to which this Interactive Object is bound. - * @param hitArea The hit area for this Interactive Object. Typically a geometry shape, like a Rectangle or Circle. - * @param hitAreaCallback The 'contains' check callback that the hit area shape will use for all hit tests. - */ - function CreateInteractiveObject(gameObject: Phaser.GameObjects.GameObject, hitArea: any, hitAreaCallback: Phaser.Types.Input.HitAreaCallback): Phaser.Types.Input.InteractiveObject; - - /** - * Creates a new Pixel Perfect Handler function. - * - * Access via `InputPlugin.makePixelPerfect` rather than calling it directly. - * @param textureManager A reference to the Texture Manager. - * @param alphaTolerance The alpha level that the pixel should be above to be included as a successful interaction. - */ - function CreatePixelPerfectHandler(textureManager: Phaser.Textures.TextureManager, alphaTolerance: number): Function; - namespace Events { /** * The Input Plugin Boot Event. @@ -48965,102 +50288,6 @@ declare namespace Phaser { } - namespace Configs { - /** - * Tatar SNES USB Controller Gamepad Configuration. - * USB Gamepad (STANDARD GAMEPAD Vendor: 0079 Product: 0011) - */ - var SNES_USB: object; - - /** - * PlayStation DualShock 4 Gamepad Configuration. - * Sony PlayStation DualShock 4 (v2) wireless controller - */ - var DUALSHOCK_4: object; - - /** - * XBox 360 Gamepad Configuration. - */ - var XBOX_360: object; - - } - - namespace Events { - /** - * The Gamepad Button Down Event. - * - * This event is dispatched by the Gamepad Plugin when a button has been pressed on any active Gamepad. - * - * Listen to this event from within a Scene using: `this.input.gamepad.on('down', listener)`. - * - * You can also listen for a DOWN event from a Gamepad instance. See the [GAMEPAD_BUTTON_DOWN]{@linkcode Phaser.Input.Gamepad.Events#event:GAMEPAD_BUTTON_DOWN} event for details. - */ - const BUTTON_DOWN: any; - - /** - * The Gamepad Button Up Event. - * - * This event is dispatched by the Gamepad Plugin when a button has been released on any active Gamepad. - * - * Listen to this event from within a Scene using: `this.input.gamepad.on('up', listener)`. - * - * You can also listen for an UP event from a Gamepad instance. See the [GAMEPAD_BUTTON_UP]{@linkcode Phaser.Input.Gamepad.Events#event:GAMEPAD_BUTTON_UP} event for details. - */ - const BUTTON_UP: any; - - /** - * The Gamepad Connected Event. - * - * This event is dispatched by the Gamepad Plugin when a Gamepad has been connected. - * - * Listen to this event from within a Scene using: `this.input.gamepad.once('connected', listener)`. - * - * Note that the browser may require you to press a button on a gamepad before it will allow you to access it, - * this is for security reasons. However, it may also trust the page already, in which case you won't get the - * 'connected' event and instead should check `GamepadPlugin.total` to see if it thinks there are any gamepads - * already connected. - */ - const CONNECTED: any; - - /** - * The Gamepad Disconnected Event. - * - * This event is dispatched by the Gamepad Plugin when a Gamepad has been disconnected. - * - * Listen to this event from within a Scene using: `this.input.gamepad.once('disconnected', listener)`. - */ - const DISCONNECTED: any; - - /** - * The Gamepad Button Down Event. - * - * This event is dispatched by a Gamepad instance when a button has been pressed on it. - * - * Listen to this event from a Gamepad instance. Once way to get this is from the `pad1`, `pad2`, etc properties on the Gamepad Plugin: - * `this.input.gamepad.pad1.on('down', listener)`. - * - * Note that you will not receive any Gamepad button events until the browser considers the Gamepad as being 'connected'. - * - * You can also listen for a DOWN event from the Gamepad Plugin. See the [BUTTON_DOWN]{@linkcode Phaser.Input.Gamepad.Events#event:BUTTON_DOWN} event for details. - */ - const GAMEPAD_BUTTON_DOWN: any; - - /** - * The Gamepad Button Up Event. - * - * This event is dispatched by a Gamepad instance when a button has been released on it. - * - * Listen to this event from a Gamepad instance. Once way to get this is from the `pad1`, `pad2`, etc properties on the Gamepad Plugin: - * `this.input.gamepad.pad1.on('up', listener)`. - * - * Note that you will not receive any Gamepad button events until the browser considers the Gamepad as being 'connected'. - * - * You can also listen for an UP event from the Gamepad Plugin. See the [BUTTON_UP]{@linkcode Phaser.Input.Gamepad.Events#event:BUTTON_UP} event for details. - */ - const GAMEPAD_BUTTON_UP: any; - - } - /** * A single Gamepad. * @@ -49432,1102 +50659,105 @@ declare namespace Phaser { } - } - - /** - * The Input Manager is responsible for handling the pointer related systems in a single Phaser Game instance. - * - * Based on the Game Config it will create handlers for mouse and touch support. - * - * Keyboard and Gamepad are plugins, handled directly by the InputPlugin class. - * - * It then manages the events, pointer creation and general hit test related operations. - * - * You rarely need to interact with the Input Manager directly, and as such, all of its properties and methods - * should be considered private. Instead, you should use the Input Plugin, which is a Scene level system, responsible - * for dealing with all input events for a Scene. - */ - class InputManager { - /** - * - * @param game The Game instance that owns the Input Manager. - * @param config The Input Configuration object, as set in the Game Config. - */ - constructor(game: Phaser.Game, config: object); - - /** - * The Game instance that owns the Input Manager. - * A Game only maintains on instance of the Input Manager at any time. - */ - readonly game: Phaser.Game; - - /** - * A reference to the global Game Scale Manager. - * Used for all bounds checks and pointer scaling. - */ - scaleManager: Phaser.Scale.ScaleManager; - - /** - * The Canvas that is used for all DOM event input listeners. - */ - canvas: HTMLCanvasElement; - - /** - * The Game Configuration object, as set during the game boot. - */ - config: Phaser.Core.Config; - - /** - * If set, the Input Manager will run its update loop every frame. - */ - enabled: boolean; - - /** - * The Event Emitter instance that the Input Manager uses to emit events from. - */ - events: Phaser.Events.EventEmitter; - - /** - * Are any mouse or touch pointers currently over the game canvas? - * This is updated automatically by the canvas over and out handlers. - */ - readonly isOver: boolean; - - /** - * The default CSS cursor to be used when interacting with your game. - * - * See the `setDefaultCursor` method for more details. - */ - defaultCursor: string; - - /** - * A reference to the Keyboard Manager class, if enabled via the `input.keyboard` Game Config property. - */ - keyboard: Phaser.Input.Keyboard.KeyboardManager; - - /** - * A reference to the Mouse Manager class, if enabled via the `input.mouse` Game Config property. - */ - mouse: Phaser.Input.Mouse.MouseManager; - - /** - * A reference to the Touch Manager class, if enabled via the `input.touch` Game Config property. - */ - touch: Phaser.Input.Touch.TouchManager; - - /** - * An array of Pointers that have been added to the game. - * The first entry is reserved for the Mouse Pointer, the rest are Touch Pointers. - * - * By default there is 1 touch pointer enabled. If you need more use the `addPointer` method to start them, - * or set the `input.activePointers` property in the Game Config. - */ - pointers: Phaser.Input.Pointer[]; - - /** - * The number of touch objects activated and being processed each update. - * - * You can change this by either calling `addPointer` at run-time, or by - * setting the `input.activePointers` property in the Game Config. - */ - readonly pointersTotal: number; - - /** - * The mouse has its own unique Pointer object, which you can reference directly if making a _desktop specific game_. - * If you are supporting both desktop and touch devices then do not use this property, instead use `activePointer` - * which will always map to the most recently interacted pointer. - */ - mousePointer: Phaser.Input.Pointer; - - /** - * The most recently active Pointer object. - * - * If you've only 1 Pointer in your game then this will accurately be either the first finger touched, or the mouse. - * - * If your game doesn't need to support multi-touch then you can safely use this property in all of your game - * code and it will adapt to be either the mouse or the touch, based on device. - */ - activePointer: Phaser.Input.Pointer; - - /** - * If the top-most Scene in the Scene List receives an input it will stop input from - * propagating any lower down the scene list, i.e. if you have a UI Scene at the top - * and click something on it, that click will not then be passed down to any other - * Scene below. Disable this to have input events passed through all Scenes, all the time. - */ - globalTopOnly: boolean; - - /** - * The time this Input Manager was last updated. - * This value is populated by the Game Step each frame. - */ - readonly time: number; - - /** - * The Boot handler is called by Phaser.Game when it first starts up. - * The renderer is available by now. - */ - protected boot(): void; - - /** - * Tells the Input system to set a custom cursor. - * - * This cursor will be the default cursor used when interacting with the game canvas. - * - * If an Interactive Object also sets a custom cursor, this is the cursor that is reset after its use. - * - * Any valid CSS cursor value is allowed, including paths to image files, i.e.: - * - * ```javascript - * this.input.setDefaultCursor('url(assets/cursors/sword.cur), pointer'); - * ``` - * - * Please read about the differences between browsers when it comes to the file formats and sizes they support: - * - * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor - * https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_User_Interface/Using_URL_values_for_the_cursor_property - * - * It's up to you to pick a suitable cursor format that works across the range of browsers you need to support. - * @param cursor The CSS to be used when setting the default cursor. - */ - setDefaultCursor(cursor: string): void; - - /** - * Adds new Pointer objects to the Input Manager. - * - * By default Phaser creates 2 pointer objects: `mousePointer` and `pointer1`. - * - * You can create more either by calling this method, or by setting the `input.activePointers` property - * in the Game Config, up to a maximum of 10 pointers. - * - * The first 10 pointers are available via the `InputPlugin.pointerX` properties, once they have been added - * via this method. - * @param quantity The number of new Pointers to create. A maximum of 10 is allowed in total. Default 1. - */ - addPointer(quantity?: number): Phaser.Input.Pointer[]; - - /** - * Internal method that gets a list of all the active Input Plugins in the game - * and updates each of them in turn, in reverse order (top to bottom), to allow - * for DOM top-level event handling simulation. - * @param type The type of event to process. - * @param pointers An array of Pointers on which the event occurred. - */ - updateInputPlugins(type: number, pointers: Phaser.Input.Pointer[]): void; - - /** - * Performs a hit test using the given Pointer and camera, against an array of interactive Game Objects. - * - * The Game Objects are culled against the camera, and then the coordinates are translated into the local camera space - * and used to determine if they fall within the remaining Game Objects hit areas or not. - * - * If nothing is matched an empty array is returned. - * - * This method is called automatically by InputPlugin.hitTestPointer and doesn't usually need to be invoked directly. - * @param pointer The Pointer to test against. - * @param gameObjects An array of interactive Game Objects to check. - * @param camera The Camera which is being tested against. - * @param output An array to store the results in. If not given, a new empty array is created. - */ - hitTest(pointer: Phaser.Input.Pointer, gameObjects: any[], camera: Phaser.Cameras.Scene2D.Camera, output?: any[]): any[]; - - /** - * Checks if the given x and y coordinate are within the hit area of the Game Object. - * - * This method assumes that the coordinate values have already been translated into the space of the Game Object. - * - * If the coordinates are within the hit area they are set into the Game Objects Input `localX` and `localY` properties. - * @param gameObject The interactive Game Object to check against. - * @param x The translated x coordinate for the hit test. - * @param y The translated y coordinate for the hit test. - */ - pointWithinHitArea(gameObject: Phaser.GameObjects.GameObject, x: number, y: number): boolean; - - /** - * Checks if the given x and y coordinate are within the hit area of the Interactive Object. - * - * This method assumes that the coordinate values have already been translated into the space of the Interactive Object. - * - * If the coordinates are within the hit area they are set into the Interactive Objects Input `localX` and `localY` properties. - * @param object The Interactive Object to check against. - * @param x The translated x coordinate for the hit test. - * @param y The translated y coordinate for the hit test. - */ - pointWithinInteractiveObject(object: Phaser.Types.Input.InteractiveObject, x: number, y: number): boolean; - - /** - * Transforms the pageX and pageY values of a Pointer into the scaled coordinate space of the Input Manager. - * @param pointer The Pointer to transform the values for. - * @param pageX The Page X value. - * @param pageY The Page Y value. - * @param wasMove Are we transforming the Pointer from a move event, or an up / down event? - */ - transformPointer(pointer: Phaser.Input.Pointer, pageX: number, pageY: number, wasMove: boolean): void; - - /** - * Destroys the Input Manager and all of its systems. - * - * There is no way to recover from doing this. - */ - destroy(): void; - - } - - /** - * The Input Plugin belongs to a Scene and handles all input related events and operations for it. - * - * You can access it from within a Scene using `this.input`. - * - * It emits events directly. For example, you can do: - * - * ```javascript - * this.input.on('pointerdown', callback, context); - * ``` - * - * To listen for a pointer down event anywhere on the game canvas. - * - * Game Objects can be enabled for input by calling their `setInteractive` method. After which they - * will directly emit input events: - * - * ```javascript - * var sprite = this.add.sprite(x, y, texture); - * sprite.setInteractive(); - * sprite.on('pointerdown', callback, context); - * ``` - * - * There are lots of game configuration options available relating to input. - * See the [Input Config object]{@linkcode Phaser.Types.Core.InputConfig} for more details, including how to deal with Phaser - * listening for input events outside of the canvas, how to set a default number of pointers, input - * capture settings and more. - * - * Please also see the Input examples and tutorials for further information. - * - * **Incorrect input coordinates with Angular** - * - * If you are using Phaser within Angular, and use nglf or the router, to make the component in which the Phaser game resides - * change state (i.e. appear or disappear) then you'll need to notify the Scale Manager about this, as Angular will mess with - * the DOM in a way in which Phaser can't detect directly. Call `this.scale.updateBounds()` as part of your game init in order - * to refresh the canvas DOM bounds values, which Phaser uses for input point position calculations. - */ - class InputPlugin extends Phaser.Events.EventEmitter { - /** - * - * @param scene A reference to the Scene that this Input Plugin is responsible for. - */ - constructor(scene: Phaser.Scene); - - /** - * An instance of the Gamepad Plugin class, if enabled via the `input.gamepad` Scene or Game Config property. - * Use this to create access Gamepads connected to the browser and respond to gamepad buttons. - */ - gamepad: Phaser.Input.Gamepad.GamepadPlugin; - - /** - * A reference to the Scene that this Input Plugin is responsible for. - */ - scene: Phaser.Scene; - - /** - * A reference to the Scene Systems class. - */ - systems: Phaser.Scenes.Systems; - - /** - * A reference to the Scene Systems Settings. - */ - settings: Phaser.Types.Scenes.SettingsObject; - - /** - * A reference to the Game Input Manager. - */ - manager: Phaser.Input.InputManager; - - /** - * If `true` this Input Plugin will process DOM input events. - */ - enabled: boolean; - - /** - * A reference to the Scene Display List. This property is set during the `boot` method. - */ - displayList: Phaser.GameObjects.DisplayList; - - /** - * A reference to the Scene Cameras Manager. This property is set during the `boot` method. - */ - cameras: Phaser.Cameras.Scene2D.CameraManager; - - /** - * A reference to the Mouse Manager. - * - * This property is only set if Mouse support has been enabled in your Game Configuration file. - * - * If you just wish to get access to the mouse pointer, use the `mousePointer` property instead. - */ - mouse: Phaser.Input.Mouse.MouseManager; - - /** - * When set to `true` (the default) the Input Plugin will emulate DOM behavior by only emitting events from - * the top-most Game Objects in the Display List. - * - * If set to `false` it will emit events from all Game Objects below a Pointer, not just the top one. - */ - topOnly: boolean; - - /** - * How often should the Pointers be checked? - * - * The value is a time, given in ms, and is the time that must have elapsed between game steps before - * the Pointers will be polled again. When a pointer is polled it runs a hit test to see which Game - * Objects are currently below it, or being interacted with it. - * - * Pointers will *always* be checked if they have been moved by the user, or press or released. - * - * This property only controls how often they will be polled if they have not been updated. - * You should set this if you want to have Game Objects constantly check against the pointers, even - * if the pointer didn't itself move. - * - * Set to 0 to poll constantly. Set to -1 to only poll on user movement. - */ - pollRate: number; - - /** - * The distance, in pixels, a pointer has to move while being held down, before it thinks it is being dragged. - */ - dragDistanceThreshold: number; - - /** - * The amount of time, in ms, a pointer has to be held down before it thinks it is dragging. - * - * The default polling rate is to poll only on move so once the time threshold is reached the - * drag event will not start until you move the mouse. If you want it to start immediately - * when the time threshold is reached, you must increase the polling rate by calling - * [setPollAlways]{@linkcode Phaser.Input.InputPlugin#setPollAlways} or - * [setPollRate]{@linkcode Phaser.Input.InputPlugin#setPollRate}. - */ - dragTimeThreshold: number; - - /** - * Checks to see if both this plugin and the Scene to which it belongs is active. - */ - isActive(): boolean; - - /** - * This is called automatically by the Input Manager. - * It emits events for plugins to listen to and also handles polling updates, if enabled. - * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. - * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. - */ - updatePoll(time: number, delta: number): boolean; - - /** - * Clears a Game Object so it no longer has an Interactive Object associated with it. - * The Game Object is then queued for removal from the Input Plugin on the next update. - * @param gameObject The Game Object that will have its Interactive Object removed. - * @param skipQueue Skip adding this Game Object into the removal queue? Default false. - */ - clear(gameObject: Phaser.GameObjects.GameObject, skipQueue?: boolean): Phaser.GameObjects.GameObject; - - /** - * Disables Input on a single Game Object. - * - * An input disabled Game Object still retains its Interactive Object component and can be re-enabled - * at any time, by passing it to `InputPlugin.enable`. - * @param gameObject The Game Object to have its input system disabled. - */ - disable(gameObject: Phaser.GameObjects.GameObject): void; - - /** - * Enable a Game Object for interaction. - * - * If the Game Object already has an Interactive Object component, it is enabled and returned. - * - * Otherwise, a new Interactive Object component is created and assigned to the Game Object's `input` property. - * - * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area - * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced - * input detection. - * - * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If - * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific - * shape for it to use. - * - * You can also provide an Input Configuration Object as the only argument to this method. - * @param gameObject The Game Object to be enabled for input. - * @param hitArea Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. - * @param hitAreaCallback The 'contains' function to invoke to check if the pointer is within the hit area. - * @param dropZone Is this Game Object a drop zone or not? Default false. - */ - enable(gameObject: Phaser.GameObjects.GameObject, hitArea?: Phaser.Types.Input.InputConfiguration | any, hitAreaCallback?: Phaser.Types.Input.HitAreaCallback, dropZone?: boolean): this; - - /** - * Takes the given Pointer and performs a hit test against it, to see which interactive Game Objects - * it is currently above. - * - * The hit test is performed against which-ever Camera the Pointer is over. If it is over multiple - * cameras, it starts checking the camera at the top of the camera list, and if nothing is found, iterates down the list. - * @param pointer The Pointer to check against the Game Objects. - */ - hitTestPointer(pointer: Phaser.Input.Pointer): Phaser.GameObjects.GameObject[]; - - /** - * Returns the drag state of the given Pointer for this Input Plugin. - * - * The state will be one of the following: - * - * 0 = Not dragging anything - * 1 = Primary button down and objects below, so collect a draglist - * 2 = Pointer being checked if meets drag criteria - * 3 = Pointer meets criteria, notify the draglist - * 4 = Pointer actively dragging the draglist and has moved - * 5 = Pointer actively dragging but has been released, notify draglist - * @param pointer The Pointer to get the drag state for. - */ - getDragState(pointer: Phaser.Input.Pointer): number; - - /** - * Sets the drag state of the given Pointer for this Input Plugin. - * - * The state must be one of the following values: - * - * 0 = Not dragging anything - * 1 = Primary button down and objects below, so collect a draglist - * 2 = Pointer being checked if meets drag criteria - * 3 = Pointer meets criteria, notify the draglist - * 4 = Pointer actively dragging the draglist and has moved - * 5 = Pointer actively dragging but has been released, notify draglist - * @param pointer The Pointer to set the drag state for. - * @param state The drag state value. An integer between 0 and 5. - */ - setDragState(pointer: Phaser.Input.Pointer, state: number): void; - - /** - * Sets the draggable state of the given array of Game Objects. - * - * They can either be set to be draggable, or can have their draggable state removed by passing `false`. - * - * A Game Object will not fire drag events unless it has been specifically enabled for drag. - * @param gameObjects An array of Game Objects to change the draggable state on. - * @param value Set to `true` if the Game Objects should be made draggable, `false` if they should be unset. Default true. - */ - setDraggable(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], value?: boolean): this; - - /** - * Creates a function that can be passed to `setInteractive`, `enable` or `setHitArea` that will handle - * pixel-perfect input detection on an Image or Sprite based Game Object, or any custom class that extends them. - * - * The following will create a sprite that is clickable on any pixel that has an alpha value >= 1. - * - * ```javascript - * this.add.sprite(x, y, key).setInteractive(this.input.makePixelPerfect()); - * ``` - * - * The following will create a sprite that is clickable on any pixel that has an alpha value >= 150. - * - * ```javascript - * this.add.sprite(x, y, key).setInteractive(this.input.makePixelPerfect(150)); - * ``` - * - * Once you have made an Interactive Object pixel perfect it impacts all input related events for it: down, up, - * dragstart, drag, etc. - * - * As a pointer interacts with the Game Object it will constantly poll the texture, extracting a single pixel from - * the given coordinates and checking its color values. This is an expensive process, so should only be enabled on - * Game Objects that really need it. - * - * You cannot make non-texture based Game Objects pixel perfect. So this will not work on Graphics, BitmapText, - * Render Textures, Text, Tilemaps, Containers or Particles. - * @param alphaTolerance The alpha level that the pixel should be above to be included as a successful interaction. Default 1. - */ - makePixelPerfect(alphaTolerance?: number): Function; - - /** - * Sets the hit area for the given array of Game Objects. - * - * A hit area is typically one of the geometric shapes Phaser provides, such as a `Phaser.Geom.Rectangle` - * or `Phaser.Geom.Circle`. However, it can be any object as long as it works with the provided callback. - * - * If no hit area is provided a Rectangle is created based on the size of the Game Object, if possible - * to calculate. - * - * The hit area callback is the function that takes an `x` and `y` coordinate and returns a boolean if - * those values fall within the area of the shape or not. All of the Phaser geometry objects provide this, - * such as `Phaser.Geom.Rectangle.Contains`. - * @param gameObjects An array of Game Objects to set the hit area on. - * @param hitArea Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. - * @param hitAreaCallback The 'contains' function to invoke to check if the pointer is within the hit area. - */ - setHitArea(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], hitArea?: Phaser.Types.Input.InputConfiguration | any, hitAreaCallback?: Phaser.Types.Input.HitAreaCallback): this; - - /** - * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Circle` shape, using - * the given coordinates and radius to control its position and size. - * @param gameObjects An array of Game Objects to set as having a circle hit area. - * @param x The center of the circle. - * @param y The center of the circle. - * @param radius The radius of the circle. - * @param callback The hit area callback. If undefined it uses Circle.Contains. - */ - setHitAreaCircle(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], x: number, y: number, radius: number, callback?: Phaser.Types.Input.HitAreaCallback): this; - - /** - * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Ellipse` shape, using - * the given coordinates and dimensions to control its position and size. - * @param gameObjects An array of Game Objects to set as having an ellipse hit area. - * @param x The center of the ellipse. - * @param y The center of the ellipse. - * @param width The width of the ellipse. - * @param height The height of the ellipse. - * @param callback The hit area callback. If undefined it uses Ellipse.Contains. - */ - setHitAreaEllipse(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], x: number, y: number, width: number, height: number, callback?: Phaser.Types.Input.HitAreaCallback): this; - - /** - * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Rectangle` shape, using - * the Game Objects texture frame to define the position and size of the hit area. - * @param gameObjects An array of Game Objects to set as having an ellipse hit area. - * @param callback The hit area callback. If undefined it uses Rectangle.Contains. - */ - setHitAreaFromTexture(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], callback?: Phaser.Types.Input.HitAreaCallback): this; - - /** - * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Rectangle` shape, using - * the given coordinates and dimensions to control its position and size. - * @param gameObjects An array of Game Objects to set as having a rectangular hit area. - * @param x The top-left of the rectangle. - * @param y The top-left of the rectangle. - * @param width The width of the rectangle. - * @param height The height of the rectangle. - * @param callback The hit area callback. If undefined it uses Rectangle.Contains. - */ - setHitAreaRectangle(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], x: number, y: number, width: number, height: number, callback?: Phaser.Types.Input.HitAreaCallback): this; - - /** - * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Triangle` shape, using - * the given coordinates to control the position of its points. - * @param gameObjects An array of Game Objects to set as having a triangular hit area. - * @param x1 The x coordinate of the first point of the triangle. - * @param y1 The y coordinate of the first point of the triangle. - * @param x2 The x coordinate of the second point of the triangle. - * @param y2 The y coordinate of the second point of the triangle. - * @param x3 The x coordinate of the third point of the triangle. - * @param y3 The y coordinate of the third point of the triangle. - * @param callback The hit area callback. If undefined it uses Triangle.Contains. - */ - setHitAreaTriangle(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, callback?: Phaser.Types.Input.HitAreaCallback): this; - - /** - * Creates an Input Debug Shape for the given Game Object. - * - * The Game Object must have _already_ been enabled for input prior to calling this method. - * - * This is intended to assist you during development and debugging. - * - * Debug Shapes can only be created for Game Objects that are using standard Phaser Geometry for input, - * including: Circle, Ellipse, Line, Polygon, Rectangle and Triangle. - * - * Game Objects that are using their automatic hit areas are using Rectangles by default, so will also work. - * - * The Debug Shape is created and added to the display list and is then kept in sync with the Game Object - * it is connected with. Should you need to modify it yourself, such as to hide it, you can access it via - * the Game Object property: `GameObject.input.hitAreaDebug`. - * - * Calling this method on a Game Object that already has a Debug Shape will first destroy the old shape, - * before creating a new one. If you wish to remove the Debug Shape entirely, you should call the - * method `InputPlugin.removeDebug`. - * - * Note that the debug shape will only show the outline of the input area. If the input test is using a - * pixel perfect check, for example, then this is not displayed. If you are using a custom shape, that - * doesn't extend one of the base Phaser Geometry objects, as your hit area, then this method will not - * work. - * @param gameObject The Game Object to create the input debug shape for. - * @param color The outline color of the debug shape. Default 0x00ff00. - */ - enableDebug(gameObject: Phaser.GameObjects.GameObject, color?: number): this; - - /** - * Removes an Input Debug Shape from the given Game Object. - * - * The shape is destroyed immediately and the `hitAreaDebug` property is set to `null`. - * @param gameObject The Game Object to remove the input debug shape from. - */ - removeDebug(gameObject: Phaser.GameObjects.GameObject): this; - - /** - * Sets the Pointers to always poll. - * - * When a pointer is polled it runs a hit test to see which Game Objects are currently below it, - * or being interacted with it, regardless if the Pointer has actually moved or not. - * - * You should enable this if you want objects in your game to fire over / out events, and the objects - * are constantly moving, but the pointer may not have. Polling every frame has additional computation - * costs, especially if there are a large number of interactive objects in your game. - */ - setPollAlways(): this; - - /** - * Sets the Pointers to only poll when they are moved or updated. - * - * When a pointer is polled it runs a hit test to see which Game Objects are currently below it, - * or being interacted with it. - */ - setPollOnMove(): this; - - /** - * Sets the poll rate value. This is the amount of time that should have elapsed before a pointer - * will be polled again. See the `setPollAlways` and `setPollOnMove` methods. - * @param value The amount of time, in ms, that should elapsed before re-polling the pointers. - */ - setPollRate(value: number): this; - - /** - * When set to `true` the global Input Manager will emulate DOM behavior by only emitting events from - * the top-most Scene in the Scene List. By default, if a Scene receives an input event it will then stop the event - * from flowing down to any Scenes below it in the Scene list. To disable this behavior call this method with `false`. - * @param value Set to `true` to stop processing input events on the Scene that receives it, or `false` to let the event continue down the Scene list. - */ - setGlobalTopOnly(value: boolean): this; - - /** - * When set to `true` this Input Plugin will emulate DOM behavior by only emitting events from - * the top-most Game Objects in the Display List. - * - * If set to `false` it will emit events from all Game Objects below a Pointer, not just the top one. - * @param value `true` to only include the top-most Game Object, or `false` to include all Game Objects in a hit test. - */ - setTopOnly(value: boolean): this; - - /** - * Given an array of Game Objects and a Pointer, sort the array and return it, - * so that the objects are in render order with the lowest at the bottom. - * @param gameObjects An array of Game Objects to be sorted. - * @param pointer The Pointer to check against the Game Objects. - */ - sortGameObjects(gameObjects: Phaser.GameObjects.GameObject[], pointer: Phaser.Input.Pointer): Phaser.GameObjects.GameObject[]; - - /** - * Given an array of Drop Zone Game Objects, sort the array and return it, - * so that the objects are in depth index order with the lowest at the bottom. - * @param gameObjects An array of Game Objects to be sorted. - */ - sortDropZones(gameObjects: Phaser.GameObjects.GameObject[]): Phaser.GameObjects.GameObject[]; - - /** - * This method should be called from within an input event handler, such as `pointerdown`. - * - * When called, it stops the Input Manager from allowing _this specific event_ to be processed by any other Scene - * not yet handled in the scene list. - */ - stopPropagation(): this; - - /** - * Adds new Pointer objects to the Input Manager. - * - * By default Phaser creates 2 pointer objects: `mousePointer` and `pointer1`. - * - * You can create more either by calling this method, or by setting the `input.activePointers` property - * in the Game Config, up to a maximum of 10 pointers. - * - * The first 10 pointers are available via the `InputPlugin.pointerX` properties, once they have been added - * via this method. - * @param quantity The number of new Pointers to create. A maximum of 10 is allowed in total. Default 1. - */ - addPointer(quantity?: number): Phaser.Input.Pointer[]; - - /** - * Tells the Input system to set a custom cursor. - * - * This cursor will be the default cursor used when interacting with the game canvas. - * - * If an Interactive Object also sets a custom cursor, this is the cursor that is reset after its use. - * - * Any valid CSS cursor value is allowed, including paths to image files, i.e.: - * - * ```javascript - * this.input.setDefaultCursor('url(assets/cursors/sword.cur), pointer'); - * ``` - * - * Please read about the differences between browsers when it comes to the file formats and sizes they support: - * - * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor - * https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_User_Interface/Using_URL_values_for_the_cursor_property - * - * It's up to you to pick a suitable cursor format that works across the range of browsers you need to support. - * @param cursor The CSS to be used when setting the default cursor. - */ - setDefaultCursor(cursor: string): this; - - /** - * The x coordinates of the ActivePointer based on the first camera in the camera list. - * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. - */ - readonly x: number; - - /** - * The y coordinates of the ActivePointer based on the first camera in the camera list. - * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. - */ - readonly y: number; - - /** - * Are any mouse or touch pointers currently over the game canvas? - */ - readonly isOver: boolean; - - /** - * The mouse has its own unique Pointer object, which you can reference directly if making a _desktop specific game_. - * If you are supporting both desktop and touch devices then do not use this property, instead use `activePointer` - * which will always map to the most recently interacted pointer. - */ - readonly mousePointer: Phaser.Input.Pointer; - - /** - * The current active input Pointer. - */ - readonly activePointer: Phaser.Input.Pointer; - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - */ - readonly pointer1: Phaser.Input.Pointer; - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - */ - readonly pointer2: Phaser.Input.Pointer; - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - */ - readonly pointer3: Phaser.Input.Pointer; - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - */ - readonly pointer4: Phaser.Input.Pointer; - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - */ - readonly pointer5: Phaser.Input.Pointer; - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - */ - readonly pointer6: Phaser.Input.Pointer; - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - */ - readonly pointer7: Phaser.Input.Pointer; - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - */ - readonly pointer8: Phaser.Input.Pointer; - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - */ - readonly pointer9: Phaser.Input.Pointer; - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - */ - readonly pointer10: Phaser.Input.Pointer; - - /** - * An instance of the Keyboard Plugin class, if enabled via the `input.keyboard` Scene or Game Config property. - * Use this to create Key objects and listen for keyboard specific events. - */ - keyboard: Phaser.Input.Keyboard.KeyboardPlugin; - - } - - namespace InputPluginCache { - /** - * Static method called directly by the Core internal Plugins. - * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) - * Plugin is the object to instantiate to create the plugin - * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) - * @param key A reference used to get this plugin from the plugin cache. - * @param plugin The plugin to be stored. Should be the core object, not instantiated. - * @param mapping If this plugin is to be injected into the Input Plugin, this is the property key used. - * @param settingsKey The key in the Scene Settings to check to see if this plugin should install or not. - * @param configKey The key in the Game Config to check to see if this plugin should install or not. - */ - function register(key: string, plugin: Function, mapping: string, settingsKey: string, configKey: string): void; - - /** - * Returns the input plugin object from the cache based on the given key. - * @param key The key of the input plugin to get. - */ - function getPlugin(key: string): Phaser.Types.Input.InputPluginContainer; - - /** - * Installs all of the registered Input Plugins into the given target. - * @param target The target InputPlugin to install the plugins into. - */ - function install(target: Phaser.Input.InputPlugin): void; - - /** - * Removes an input plugin based on the given key. - * @param key The key of the input plugin to remove. - */ - function remove(key: string): void; - - } - - namespace Keyboard { - /** - * A KeyCombo will listen for a specific string of keys from the Keyboard, and when it receives them - * it will emit a `keycombomatch` event from the Keyboard Manager. - * - * The keys to be listened for can be defined as: - * - * A string (i.e. 'ATARI') - * An array of either integers (key codes) or strings, or a mixture of both - * An array of objects (such as Key objects) with a public 'keyCode' property - * - * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) - * you could pass the following array of key codes: - * - * ```javascript - * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); - * - * this.input.keyboard.on('keycombomatch', function (event) { - * console.log('Konami Code entered!'); - * }); - * ``` - * - * Or, to listen for the user entering the word PHASER: - * - * ```javascript - * this.input.keyboard.createCombo('PHASER'); - * ``` - */ - class KeyCombo { + namespace Configs { /** - * - * @param keyboardPlugin A reference to the Keyboard Plugin. - * @param keys The keys that comprise this combo. - * @param config A Key Combo configuration object. + * Tatar SNES USB Controller Gamepad Configuration. + * USB Gamepad (STANDARD GAMEPAD Vendor: 0079 Product: 0011) */ - constructor(keyboardPlugin: Phaser.Input.Keyboard.KeyboardPlugin, keys: string | number[] | object[], config?: Phaser.Types.Input.Keyboard.KeyComboConfig); + var SNES_USB: object; /** - * A reference to the Keyboard Manager + * PlayStation DualShock 4 Gamepad Configuration. + * Sony PlayStation DualShock 4 (v2) wireless controller */ - manager: Phaser.Input.Keyboard.KeyboardPlugin; + var DUALSHOCK_4: object; /** - * A flag that controls if this Key Combo is actively processing keys or not. + * XBox 360 Gamepad Configuration. */ - enabled: boolean; - - /** - * An array of the keycodes that comprise this combo. - */ - keyCodes: any[]; - - /** - * The current keyCode the combo is waiting for. - */ - current: number; - - /** - * The current index of the key being waited for in the 'keys' string. - */ - index: number; - - /** - * The length of this combo (in keycodes) - */ - size: number; - - /** - * The time the previous key in the combo was matched. - */ - timeLastMatched: number; - - /** - * Has this Key Combo been matched yet? - */ - matched: boolean; - - /** - * The time the entire combo was matched. - */ - timeMatched: number; - - /** - * If they press the wrong key do we reset the combo? - */ - resetOnWrongKey: boolean; - - /** - * The max delay in ms between each key press. Above this the combo is reset. 0 means disabled. - */ - maxKeyDelay: number; - - /** - * If previously matched and they press the first key of the combo again, will it reset? - */ - resetOnMatch: boolean; - - /** - * If the combo matches, will it delete itself? - */ - deleteOnMatch: boolean; - - /** - * How far complete is this combo? A value between 0 and 1. - */ - readonly progress: number; - - /** - * Destroys this Key Combo and all of its references. - */ - destroy(): void; + var XBOX_360: object; } namespace Events { /** - * The Global Key Down Event. + * The Gamepad Button Down Event. * - * This event is dispatched by the Keyboard Plugin when any key on the keyboard is pressed down. + * This event is dispatched by the Gamepad Plugin when a button has been pressed on any active Gamepad. * - * Listen to this event from within a Scene using: `this.input.keyboard.on('keydown', listener)`. + * Listen to this event from within a Scene using: `this.input.gamepad.on('down', listener)`. * - * You can also listen for a specific key being pressed. See [Keyboard.Events.KEY_DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:KEY_DOWN} for details. - * - * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:DOWN} for details. - * - * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. - * Read [this article on ghosting]{@link http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/} for details. - * - * Also, please be aware that some browser extensions can disable or override Phaser keyboard handling. - * For example, the Chrome extension vimium is known to disable Phaser from using the D key, while EverNote disables the backtick key. - * There are others. So, please check your extensions if you find you have specific keys that don't work. + * You can also listen for a DOWN event from a Gamepad instance. See the [GAMEPAD_BUTTON_DOWN]{@linkcode Phaser.Input.Gamepad.Events#event:GAMEPAD_BUTTON_DOWN} event for details. */ - const ANY_KEY_DOWN: any; + const BUTTON_DOWN: any; /** - * The Global Key Up Event. + * The Gamepad Button Up Event. * - * This event is dispatched by the Keyboard Plugin when any key on the keyboard is released. + * This event is dispatched by the Gamepad Plugin when a button has been released on any active Gamepad. * - * Listen to this event from within a Scene using: `this.input.keyboard.on('keyup', listener)`. + * Listen to this event from within a Scene using: `this.input.gamepad.on('up', listener)`. * - * You can also listen for a specific key being released. See [Keyboard.Events.KEY_UP]{@linkcode Phaser.Input.Keyboard.Events#event:KEY_UP} for details. - * - * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.UP]{@linkcode Phaser.Input.Keyboard.Events#event:UP} for details. + * You can also listen for an UP event from a Gamepad instance. See the [GAMEPAD_BUTTON_UP]{@linkcode Phaser.Input.Gamepad.Events#event:GAMEPAD_BUTTON_UP} event for details. */ - const ANY_KEY_UP: any; + const BUTTON_UP: any; /** - * The Key Combo Match Event. + * The Gamepad Connected Event. * - * This event is dispatched by the Keyboard Plugin when a [Key Combo]{@link Phaser.Input.Keyboard.KeyCombo} is matched. + * This event is dispatched by the Gamepad Plugin when a Gamepad has been connected. * - * Listen for this event from the Key Plugin after a combo has been created: + * Listen to this event from within a Scene using: `this.input.gamepad.once('connected', listener)`. * - * ```javascript - * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); - * - * this.input.keyboard.on('keycombomatch', function (event) { - * console.log('Konami Code entered!'); - * }); - * ``` + * Note that the browser may require you to press a button on a gamepad before it will allow you to access it, + * this is for security reasons. However, it may also trust the page already, in which case you won't get the + * 'connected' event and instead should check `GamepadPlugin.total` to see if it thinks there are any gamepads + * already connected. */ - const COMBO_MATCH: any; + const CONNECTED: any; /** - * The Key Down Event. + * The Gamepad Disconnected Event. * - * This event is dispatched by a [Key]{@link Phaser.Input.Keyboard.Key} object when it is pressed. + * This event is dispatched by the Gamepad Plugin when a Gamepad has been disconnected. * - * Listen for this event from the Key object instance directly: - * - * ```javascript - * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); - * - * spaceBar.on('down', listener) - * ``` - * - * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_DOWN} for details. + * Listen to this event from within a Scene using: `this.input.gamepad.once('disconnected', listener)`. */ - const DOWN: any; + const DISCONNECTED: any; /** - * The Key Down Event. + * The Gamepad Button Down Event. * - * This event is dispatched by the Keyboard Plugin when any key on the keyboard is pressed down. + * This event is dispatched by a Gamepad instance when a button has been pressed on it. * - * Unlike the `ANY_KEY_DOWN` event, this one has a special dynamic event name. For example, to listen for the `A` key being pressed - * use the following from within a Scene: `this.input.keyboard.on('keydown-A', listener)`. You can replace the `-A` part of the event - * name with any valid [Key Code string]{@link Phaser.Input.Keyboard.KeyCodes}. For example, this will listen for the space bar: - * `this.input.keyboard.on('keydown-SPACE', listener)`. + * Listen to this event from a Gamepad instance. Once way to get this is from the `pad1`, `pad2`, etc properties on the Gamepad Plugin: + * `this.input.gamepad.pad1.on('down', listener)`. * - * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_DOWN} for details. + * Note that you will not receive any Gamepad button events until the browser considers the Gamepad as being 'connected'. * - * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:DOWN} for details. - * - * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. - * Read [this article on ghosting]{@link http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/} for details. - * - * Also, please be aware that some browser extensions can disable or override Phaser keyboard handling. - * For example, the Chrome extension vimium is known to disable Phaser from using the D key, while EverNote disables the backtick key. - * There are others. So, please check your extensions if you find you have specific keys that don't work. + * You can also listen for a DOWN event from the Gamepad Plugin. See the [BUTTON_DOWN]{@linkcode Phaser.Input.Gamepad.Events#event:BUTTON_DOWN} event for details. */ - const KEY_DOWN: any; + const GAMEPAD_BUTTON_DOWN: any; /** - * The Key Up Event. + * The Gamepad Button Up Event. * - * This event is dispatched by the Keyboard Plugin when any key on the keyboard is released. + * This event is dispatched by a Gamepad instance when a button has been released on it. * - * Unlike the `ANY_KEY_UP` event, this one has a special dynamic event name. For example, to listen for the `A` key being released - * use the following from within a Scene: `this.input.keyboard.on('keyup-A', listener)`. You can replace the `-A` part of the event - * name with any valid [Key Code string]{@link Phaser.Input.Keyboard.KeyCodes}. For example, this will listen for the space bar: - * `this.input.keyboard.on('keyup-SPACE', listener)`. + * Listen to this event from a Gamepad instance. Once way to get this is from the `pad1`, `pad2`, etc properties on the Gamepad Plugin: + * `this.input.gamepad.pad1.on('up', listener)`. * - * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_UP]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_UP} for details. + * Note that you will not receive any Gamepad button events until the browser considers the Gamepad as being 'connected'. * - * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.UP]{@linkcode Phaser.Input.Keyboard.Events#event:UP} for details. + * You can also listen for an UP event from the Gamepad Plugin. See the [BUTTON_UP]{@linkcode Phaser.Input.Gamepad.Events#event:BUTTON_UP} event for details. */ - const KEY_UP: any; - - /** - * The Key Up Event. - * - * This event is dispatched by a [Key]{@link Phaser.Input.Keyboard.Key} object when it is released. - * - * Listen for this event from the Key object instance directly: - * - * ```javascript - * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); - * - * spaceBar.on('up', listener) - * ``` - * - * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_UP]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_UP} for details. - */ - const UP: any; + const GAMEPAD_BUTTON_UP: any; } + } + + namespace Keyboard { /** * The Keyboard Manager is a helper class that belongs to the global Input Manager. * @@ -51001,6 +51231,245 @@ declare namespace Phaser { } + /** + * A KeyCombo will listen for a specific string of keys from the Keyboard, and when it receives them + * it will emit a `keycombomatch` event from the Keyboard Manager. + * + * The keys to be listened for can be defined as: + * + * A string (i.e. 'ATARI') + * An array of either integers (key codes) or strings, or a mixture of both + * An array of objects (such as Key objects) with a public 'keyCode' property + * + * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) + * you could pass the following array of key codes: + * + * ```javascript + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); + * + * this.input.keyboard.on('keycombomatch', function (event) { + * console.log('Konami Code entered!'); + * }); + * ``` + * + * Or, to listen for the user entering the word PHASER: + * + * ```javascript + * this.input.keyboard.createCombo('PHASER'); + * ``` + */ + class KeyCombo { + /** + * + * @param keyboardPlugin A reference to the Keyboard Plugin. + * @param keys The keys that comprise this combo. + * @param config A Key Combo configuration object. + */ + constructor(keyboardPlugin: Phaser.Input.Keyboard.KeyboardPlugin, keys: string | number[] | object[], config?: Phaser.Types.Input.Keyboard.KeyComboConfig); + + /** + * A reference to the Keyboard Manager + */ + manager: Phaser.Input.Keyboard.KeyboardPlugin; + + /** + * A flag that controls if this Key Combo is actively processing keys or not. + */ + enabled: boolean; + + /** + * An array of the keycodes that comprise this combo. + */ + keyCodes: any[]; + + /** + * The current keyCode the combo is waiting for. + */ + current: number; + + /** + * The current index of the key being waited for in the 'keys' string. + */ + index: number; + + /** + * The length of this combo (in keycodes) + */ + size: number; + + /** + * The time the previous key in the combo was matched. + */ + timeLastMatched: number; + + /** + * Has this Key Combo been matched yet? + */ + matched: boolean; + + /** + * The time the entire combo was matched. + */ + timeMatched: number; + + /** + * If they press the wrong key do we reset the combo? + */ + resetOnWrongKey: boolean; + + /** + * The max delay in ms between each key press. Above this the combo is reset. 0 means disabled. + */ + maxKeyDelay: number; + + /** + * If previously matched and they press the first key of the combo again, will it reset? + */ + resetOnMatch: boolean; + + /** + * If the combo matches, will it delete itself? + */ + deleteOnMatch: boolean; + + /** + * How far complete is this combo? A value between 0 and 1. + */ + readonly progress: number; + + /** + * Destroys this Key Combo and all of its references. + */ + destroy(): void; + + } + + namespace Events { + /** + * The Global Key Down Event. + * + * This event is dispatched by the Keyboard Plugin when any key on the keyboard is pressed down. + * + * Listen to this event from within a Scene using: `this.input.keyboard.on('keydown', listener)`. + * + * You can also listen for a specific key being pressed. See [Keyboard.Events.KEY_DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:KEY_DOWN} for details. + * + * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:DOWN} for details. + * + * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. + * Read [this article on ghosting]{@link http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/} for details. + * + * Also, please be aware that some browser extensions can disable or override Phaser keyboard handling. + * For example, the Chrome extension vimium is known to disable Phaser from using the D key, while EverNote disables the backtick key. + * There are others. So, please check your extensions if you find you have specific keys that don't work. + */ + const ANY_KEY_DOWN: any; + + /** + * The Global Key Up Event. + * + * This event is dispatched by the Keyboard Plugin when any key on the keyboard is released. + * + * Listen to this event from within a Scene using: `this.input.keyboard.on('keyup', listener)`. + * + * You can also listen for a specific key being released. See [Keyboard.Events.KEY_UP]{@linkcode Phaser.Input.Keyboard.Events#event:KEY_UP} for details. + * + * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.UP]{@linkcode Phaser.Input.Keyboard.Events#event:UP} for details. + */ + const ANY_KEY_UP: any; + + /** + * The Key Combo Match Event. + * + * This event is dispatched by the Keyboard Plugin when a [Key Combo]{@link Phaser.Input.Keyboard.KeyCombo} is matched. + * + * Listen for this event from the Key Plugin after a combo has been created: + * + * ```javascript + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); + * + * this.input.keyboard.on('keycombomatch', function (event) { + * console.log('Konami Code entered!'); + * }); + * ``` + */ + const COMBO_MATCH: any; + + /** + * The Key Down Event. + * + * This event is dispatched by a [Key]{@link Phaser.Input.Keyboard.Key} object when it is pressed. + * + * Listen for this event from the Key object instance directly: + * + * ```javascript + * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); + * + * spaceBar.on('down', listener) + * ``` + * + * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_DOWN} for details. + */ + const DOWN: any; + + /** + * The Key Down Event. + * + * This event is dispatched by the Keyboard Plugin when any key on the keyboard is pressed down. + * + * Unlike the `ANY_KEY_DOWN` event, this one has a special dynamic event name. For example, to listen for the `A` key being pressed + * use the following from within a Scene: `this.input.keyboard.on('keydown-A', listener)`. You can replace the `-A` part of the event + * name with any valid [Key Code string]{@link Phaser.Input.Keyboard.KeyCodes}. For example, this will listen for the space bar: + * `this.input.keyboard.on('keydown-SPACE', listener)`. + * + * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_DOWN} for details. + * + * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:DOWN} for details. + * + * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. + * Read [this article on ghosting]{@link http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/} for details. + * + * Also, please be aware that some browser extensions can disable or override Phaser keyboard handling. + * For example, the Chrome extension vimium is known to disable Phaser from using the D key, while EverNote disables the backtick key. + * There are others. So, please check your extensions if you find you have specific keys that don't work. + */ + const KEY_DOWN: any; + + /** + * The Key Up Event. + * + * This event is dispatched by the Keyboard Plugin when any key on the keyboard is released. + * + * Unlike the `ANY_KEY_UP` event, this one has a special dynamic event name. For example, to listen for the `A` key being released + * use the following from within a Scene: `this.input.keyboard.on('keyup-A', listener)`. You can replace the `-A` part of the event + * name with any valid [Key Code string]{@link Phaser.Input.Keyboard.KeyCodes}. For example, this will listen for the space bar: + * `this.input.keyboard.on('keyup-SPACE', listener)`. + * + * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_UP]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_UP} for details. + * + * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.UP]{@linkcode Phaser.Input.Keyboard.Events#event:UP} for details. + */ + const KEY_UP: any; + + /** + * The Key Up Event. + * + * This event is dispatched by a [Key]{@link Phaser.Input.Keyboard.Key} object when it is released. + * + * Listen for this event from the Key object instance directly: + * + * ```javascript + * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); + * + * spaceBar.on('up', listener) + * ``` + * + * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_UP]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_UP} for details. + */ + const UP: any; + + } + /** * Returns `true` if the Key was pressed down within the `duration` value given, based on the current * game clock time. Or `false` if it either isn't down, or was pressed down longer ago than the given duration. @@ -51865,468 +52334,6 @@ declare namespace Phaser { } - /** - * A Pointer object encapsulates both mouse and touch input within Phaser. - * - * By default, Phaser will create 2 pointers for your game to use. If you require more, i.e. for a multi-touch - * game, then use the `InputPlugin.addPointer` method to do so, rather than instantiating this class directly, - * otherwise it won't be managed by the input system. - * - * You can reference the current active pointer via `InputPlugin.activePointer`. You can also use the properties - * `InputPlugin.pointer1` through to `pointer10`, for each pointer you have enabled in your game. - * - * The properties of this object are set by the Input Plugin during processing. This object is then sent in all - * input related events that the Input Plugin emits, so you can reference properties from it directly in your - * callbacks. - */ - class Pointer { - /** - * - * @param manager A reference to the Input Manager. - * @param id The internal ID of this Pointer. - */ - constructor(manager: Phaser.Input.InputManager, id: number); - - /** - * A reference to the Input Manager. - */ - manager: Phaser.Input.InputManager; - - /** - * The internal ID of this Pointer. - */ - readonly id: number; - - /** - * The most recent native DOM Event this Pointer has processed. - */ - event: TouchEvent | MouseEvent; - - /** - * The DOM element the Pointer was pressed down on, taken from the DOM event. - * In a default set-up this will be the Canvas that Phaser is rendering to, or the Window element. - */ - readonly downElement: any; - - /** - * The DOM element the Pointer was released on, taken from the DOM event. - * In a default set-up this will be the Canvas that Phaser is rendering to, or the Window element. - */ - readonly upElement: any; - - /** - * The camera the Pointer interacted with during its last update. - * - * A Pointer can only ever interact with one camera at once, which will be the top-most camera - * in the list should multiple cameras be positioned on-top of each other. - */ - camera: Phaser.Cameras.Scene2D.Camera; - - /** - * A read-only property that indicates which button was pressed, or released, on the pointer - * during the most recent event. It is only set during `up` and `down` events. - * - * On Touch devices the value is always 0. - * - * Users may change the configuration of buttons on their pointing device so that if an event's button property - * is zero, it may not have been caused by the button that is physically left–most on the pointing device; - * however, it should behave as if the left button was clicked in the standard button layout. - */ - readonly button: number; - - /** - * 0: No button or un-initialized - * 1: Left button - * 2: Right button - * 4: Wheel button or middle button - * 8: 4th button (typically the "Browser Back" button) - * 16: 5th button (typically the "Browser Forward" button) - * - * For a mouse configured for left-handed use, the button actions are reversed. - * In this case, the values are read from right to left. - */ - buttons: number; - - /** - * The position of the Pointer in screen space. - */ - readonly position: Phaser.Math.Vector2; - - /** - * The previous position of the Pointer in screen space. - * - * The old x and y values are stored in here during the InputManager.transformPointer call. - * - * Use the properties `velocity`, `angle` and `distance` to create your own gesture recognition. - */ - readonly prevPosition: Phaser.Math.Vector2; - - /** - * The current velocity of the Pointer, based on its current and previous positions. - * - * This value is smoothed out each frame, according to the `motionFactor` property. - * - * This property is updated whenever the Pointer moves, regardless of any button states. In other words, - * it changes based on movement alone - a button doesn't have to be pressed first. - */ - readonly velocity: Phaser.Math.Vector2; - - /** - * The current angle the Pointer is moving, in radians, based on its previous and current position. - * - * The angle is based on the old position facing to the current position. - * - * This property is updated whenever the Pointer moves, regardless of any button states. In other words, - * it changes based on movement alone - a button doesn't have to be pressed first. - */ - readonly angle: number; - - /** - * The distance the Pointer has moved, based on its previous and current position. - * - * This value is smoothed out each frame, according to the `motionFactor` property. - * - * This property is updated whenever the Pointer moves, regardless of any button states. In other words, - * it changes based on movement alone - a button doesn't have to be pressed first. - * - * If you need the total distance travelled since the primary buttons was pressed down, - * then use the `Pointer.getDistance` method. - */ - readonly distance: number; - - /** - * The smoothing factor to apply to the Pointer position. - * - * Due to their nature, pointer positions are inherently noisy. While this is fine for lots of games, if you need cleaner positions - * then you can set this value to apply an automatic smoothing to the positions as they are recorded. - * - * The default value of zero means 'no smoothing'. - * Set to a small value, such as 0.2, to apply an average level of smoothing between positions. You can do this by changing this - * value directly, or by setting the `input.smoothFactor` property in the Game Config. - * - * Positions are only smoothed when the pointer moves. If the primary button on this Pointer enters an Up or Down state, then the position - * is always precise, and not smoothed. - */ - smoothFactor: number; - - /** - * The factor applied to the motion smoothing each frame. - * - * This value is passed to the Smooth Step Interpolation that is used to calculate the velocity, - * angle and distance of the Pointer. It's applied every frame, until the midPoint reaches the current - * position of the Pointer. 0.2 provides a good average but can be increased if you need a - * quicker update and are working in a high performance environment. Never set this value to - * zero. - */ - motionFactor: number; - - /** - * The x position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. - * - * If you wish to use this value _outside_ of an input event handler then you should update it first by calling - * the `Pointer.updateWorldPoint` method. - */ - worldX: number; - - /** - * The y position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. - * - * If you wish to use this value _outside_ of an input event handler then you should update it first by calling - * the `Pointer.updateWorldPoint` method. - */ - worldY: number; - - /** - * Time when this Pointer was most recently moved (regardless of the state of its buttons, if any) - */ - moveTime: number; - - /** - * X coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. - */ - downX: number; - - /** - * Y coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. - */ - downY: number; - - /** - * The Event timestamp when the first button, or Touch input, was pressed. Used for dragging objects. - */ - downTime: number; - - /** - * X coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. - */ - upX: number; - - /** - * Y coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. - */ - upY: number; - - /** - * The Event timestamp when the final button, or Touch input, was released. Used for dragging objects. - */ - upTime: number; - - /** - * Is the primary button down? (usually button 0, the left mouse button) - */ - primaryDown: boolean; - - /** - * Is _any_ button on this pointer considered as being down? - */ - isDown: boolean; - - /** - * Did the previous input event come from a Touch input (true) or Mouse? (false) - */ - wasTouch: boolean; - - /** - * Did this Pointer get canceled by a touchcancel event? - * - * Note: "canceled" is the American-English spelling of "cancelled". Please don't submit PRs correcting it! - */ - wasCanceled: boolean; - - /** - * If the mouse is locked, the horizontal relative movement of the Pointer in pixels since last frame. - */ - movementX: number; - - /** - * If the mouse is locked, the vertical relative movement of the Pointer in pixels since last frame. - */ - movementY: number; - - /** - * The identifier property of the Pointer as set by the DOM event when this Pointer is started. - */ - identifier: number; - - /** - * The pointerId property of the Pointer as set by the DOM event when this Pointer is started. - * The browser can and will recycle this value. - */ - pointerId: number; - - /** - * An active Pointer is one that is currently pressed down on the display. - * A Mouse is always considered as active. - */ - active: boolean; - - /** - * Is this pointer Pointer Locked? - * - * Only a mouse pointer can be locked and it only becomes locked when requested via - * the browsers Pointer Lock API. - * - * You can request this by calling the `this.input.mouse.requestPointerLock()` method from - * a `pointerdown` or `pointerup` event handler. - */ - readonly locked: boolean; - - /** - * The horizontal scroll amount that occurred due to the user moving a mouse wheel or similar input device. - */ - deltaX: number; - - /** - * The vertical scroll amount that occurred due to the user moving a mouse wheel or similar input device. - * This value will typically be less than 0 if the user scrolls up and greater than zero if scrolling down. - */ - deltaY: number; - - /** - * The z-axis scroll amount that occurred due to the user moving a mouse wheel or similar input device. - */ - deltaZ: number; - - /** - * Takes a Camera and updates this Pointer's `worldX` and `worldY` values so they are - * the result of a translation through the given Camera. - * - * Note that the values will be automatically replaced the moment the Pointer is - * updated by an input event, such as a mouse move, so should be used immediately. - * @param camera The Camera which is being tested against. - */ - updateWorldPoint(camera: Phaser.Cameras.Scene2D.Camera): this; - - /** - * Takes a Camera and returns a Vector2 containing the translated position of this Pointer - * within that Camera. This can be used to convert this Pointers position into camera space. - * @param camera The Camera to use for the translation. - * @param output A Vector2-like object in which to store the translated position. - */ - positionToCamera(camera: Phaser.Cameras.Scene2D.Camera, output?: Phaser.Math.Vector2 | object): Phaser.Math.Vector2 | object; - - /** - * Checks to see if any buttons are being held down on this Pointer. - */ - noButtonDown(): boolean; - - /** - * Checks to see if the left button is being held down on this Pointer. - */ - leftButtonDown(): boolean; - - /** - * Checks to see if the right button is being held down on this Pointer. - */ - rightButtonDown(): boolean; - - /** - * Checks to see if the middle button is being held down on this Pointer. - */ - middleButtonDown(): boolean; - - /** - * Checks to see if the back button is being held down on this Pointer. - */ - backButtonDown(): boolean; - - /** - * Checks to see if the forward button is being held down on this Pointer. - */ - forwardButtonDown(): boolean; - - /** - * Checks to see if the left button was just released on this Pointer. - */ - leftButtonReleased(): boolean; - - /** - * Checks to see if the right button was just released on this Pointer. - */ - rightButtonReleased(): boolean; - - /** - * Checks to see if the middle button was just released on this Pointer. - */ - middleButtonReleased(): boolean; - - /** - * Checks to see if the back button was just released on this Pointer. - */ - backButtonReleased(): boolean; - - /** - * Checks to see if the forward button was just released on this Pointer. - */ - forwardButtonReleased(): boolean; - - /** - * If the Pointer has a button pressed down at the time this method is called, it will return the - * distance between the Pointer's `downX` and `downY` values and the current position. - * - * If no button is held down, it will return the last recorded distance, based on where - * the Pointer was when the button was released. - * - * If you wish to get the distance being travelled currently, based on the velocity of the Pointer, - * then see the `Pointer.distance` property. - */ - getDistance(): number; - - /** - * If the Pointer has a button pressed down at the time this method is called, it will return the - * horizontal distance between the Pointer's `downX` and `downY` values and the current position. - * - * If no button is held down, it will return the last recorded horizontal distance, based on where - * the Pointer was when the button was released. - */ - getDistanceX(): number; - - /** - * If the Pointer has a button pressed down at the time this method is called, it will return the - * vertical distance between the Pointer's `downX` and `downY` values and the current position. - * - * If no button is held down, it will return the last recorded vertical distance, based on where - * the Pointer was when the button was released. - */ - getDistanceY(): number; - - /** - * If the Pointer has a button pressed down at the time this method is called, it will return the - * duration since the button was pressed down. - * - * If no button is held down, it will return the last recorded duration, based on the time - * the last button on the Pointer was released. - */ - getDuration(): number; - - /** - * If the Pointer has a button pressed down at the time this method is called, it will return the - * angle between the Pointer's `downX` and `downY` values and the current position. - * - * If no button is held down, it will return the last recorded angle, based on where - * the Pointer was when the button was released. - * - * The angle is based on the old position facing to the current position. - * - * If you wish to get the current angle, based on the velocity of the Pointer, then - * see the `Pointer.angle` property. - */ - getAngle(): number; - - /** - * Takes the previous and current Pointer positions and then generates an array of interpolated values between - * the two. The array will be populated up to the size of the `steps` argument. - * - * ```javaScript - * var points = pointer.getInterpolatedPosition(4); - * - * // points[0] = { x: 0, y: 0 } - * // points[1] = { x: 2, y: 1 } - * // points[2] = { x: 3, y: 2 } - * // points[3] = { x: 6, y: 3 } - * ``` - * - * Use this if you need to get smoothed values between the previous and current pointer positions. DOM pointer - * events can often fire faster than the main browser loop, and this will help you avoid janky movement - * especially if you have an object following a Pointer. - * - * Note that if you provide an output array it will only be populated up to the number of steps provided. - * It will not clear any previous data that may have existed beyond the range of the steps count. - * - * Internally it uses the Smooth Step interpolation calculation. - * @param steps The number of interpolation steps to use. Default 10. - * @param out An array to store the results in. If not provided a new one will be created. - */ - getInterpolatedPosition(steps?: number, out?: any[]): any[]; - - /** - * Destroys this Pointer instance and resets its external references. - */ - destroy(): void; - - /** - * The x position of this Pointer. - * The value is in screen space. - * See `worldX` to get a camera converted position. - */ - x: number; - - /** - * The y position of this Pointer. - * The value is in screen space. - * See `worldY` to get a camera converted position. - */ - y: number; - - /** - * Time when this Pointer was most recently updated by a DOM Event. - * This comes directly from the `event.timeStamp` property. - * If no event has yet taken place, it will return zero. - */ - readonly time: number; - - } - namespace Touch { /** * The Touch Manager is a helper class that belongs to the Input Manager. @@ -52454,214 +52461,6 @@ declare namespace Phaser { } namespace Loader { - /** - * The Loader is idle. - */ - var LOADER_IDLE: number; - - /** - * The Loader is actively loading. - */ - var LOADER_LOADING: number; - - /** - * The Loader is processing files is has loaded. - */ - var LOADER_PROCESSING: number; - - /** - * The Loader has completed loading and processing. - */ - var LOADER_COMPLETE: number; - - /** - * The Loader is shutting down. - */ - var LOADER_SHUTDOWN: number; - - /** - * The Loader has been destroyed. - */ - var LOADER_DESTROYED: number; - - /** - * File is in the load queue but not yet started - */ - var FILE_PENDING: number; - - /** - * File has been started to load by the loader (onLoad called) - */ - var FILE_LOADING: number; - - /** - * File has loaded successfully, awaiting processing - */ - var FILE_LOADED: number; - - /** - * File failed to load - */ - var FILE_FAILED: number; - - /** - * File is being processed (onProcess callback) - */ - var FILE_PROCESSING: number; - - /** - * The File has errored somehow during processing. - */ - var FILE_ERRORED: number; - - /** - * File has finished processing. - */ - var FILE_COMPLETE: number; - - /** - * File has been destroyed - */ - var FILE_DESTROYED: number; - - /** - * File was populated from local data and doesn't need an HTTP request - */ - var FILE_POPULATED: number; - - namespace Events { - /** - * The Loader Plugin Add File Event. - * - * This event is dispatched when a new file is successfully added to the Loader and placed into the load queue. - * - * Listen to it from a Scene using: `this.load.on('addfile', listener)`. - * - * If you add lots of files to a Loader from a `preload` method, it will dispatch this event for each one of them. - */ - const ADD: any; - - /** - * The Loader Plugin Complete Event. - * - * This event is dispatched when the Loader has fully processed everything in the load queue. - * By this point every loaded file will now be in its associated cache and ready for use. - * - * Listen to it from a Scene using: `this.load.on('complete', listener)`. - */ - const COMPLETE: any; - - /** - * The File Load Complete Event. - * - * This event is dispatched by the Loader Plugin when any file in the queue finishes loading. - * - * Listen to it from a Scene using: `this.load.on('filecomplete', listener)`. - * - * You can also listen for the completion of a specific file. See the [FILE_KEY_COMPLETE]{@linkcode Phaser.Loader.Events#event:FILE_KEY_COMPLETE} event. - */ - const FILE_COMPLETE: any; - - /** - * The File Load Complete Event. - * - * This event is dispatched by the Loader Plugin when any file in the queue finishes loading. - * - * It uses a special dynamic event name constructed from the key and type of the file. - * - * For example, if you have loaded an `image` with a key of `monster`, you can listen for it - * using the following: - * - * ```javascript - * this.load.on('filecomplete-image-monster', function (key, type, data) { - * // Your handler code - * }); - * ``` - * - * Or, if you have loaded a texture `atlas` with a key of `Level1`: - * - * ```javascript - * this.load.on('filecomplete-atlas-Level1', function (key, type, data) { - * // Your handler code - * }); - * ``` - * - * Or, if you have loaded a sprite sheet with a key of `Explosion` and a prefix of `GAMEOVER`: - * - * ```javascript - * this.load.on('filecomplete-spritesheet-GAMEOVERExplosion', function (key, type, data) { - * // Your handler code - * }); - * ``` - * - * You can also listen for the generic completion of files. See the [FILE_COMPLETE]{@linkcode Phaser.Loader.Events#event:FILE_COMPLETE} event. - */ - const FILE_KEY_COMPLETE: any; - - /** - * The File Load Error Event. - * - * This event is dispatched by the Loader Plugin when a file fails to load. - * - * Listen to it from a Scene using: `this.load.on('loaderror', listener)`. - */ - const FILE_LOAD_ERROR: any; - - /** - * The File Load Event. - * - * This event is dispatched by the Loader Plugin when a file finishes loading, - * but _before_ it is processed and added to the internal Phaser caches. - * - * Listen to it from a Scene using: `this.load.on('load', listener)`. - */ - const FILE_LOAD: any; - - /** - * The File Load Progress Event. - * - * This event is dispatched by the Loader Plugin during the load of a file, if the browser receives a DOM ProgressEvent and - * the `lengthComputable` event property is true. Depending on the size of the file and browser in use, this may, or may not happen. - * - * Listen to it from a Scene using: `this.load.on('fileprogress', listener)`. - */ - const FILE_PROGRESS: any; - - /** - * The Loader Plugin Post Process Event. - * - * This event is dispatched by the Loader Plugin when the Loader has finished loading everything in the load queue. - * It is dispatched before the internal lists are cleared and each File is destroyed. - * - * Use this hook to perform any last minute processing of files that can only happen once the - * Loader has completed, but prior to it emitting the `complete` event. - * - * Listen to it from a Scene using: `this.load.on('postprocess', listener)`. - */ - const POST_PROCESS: any; - - /** - * The Loader Plugin Progress Event. - * - * This event is dispatched when the Loader updates its load progress, typically as a result of a file having completed loading. - * - * Listen to it from a Scene using: `this.load.on('progress', listener)`. - */ - const PROGRESS: any; - - /** - * The Loader Plugin Start Event. - * - * This event is dispatched when the Loader starts running. At this point load progress is zero. - * - * This event is dispatched even if there aren't any files in the load queue. - * - * Listen to it from a Scene using: `this.load.on('start', listener)`. - */ - const START: any; - - } - /** * The base File class used by all File Types that the Loader can support. * You shouldn't create an instance of a File directly, but should extend it with your own class, setting a custom type and processing methods. @@ -52869,925 +52668,6 @@ declare namespace Phaser { } - namespace FileTypes { - /** - * A single Animation JSON File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#animation method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#animation. - */ - class AnimationJSONFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param xhrSettings Extra XHR Settings specifically for this file. - * @param dataKey When the JSON file loads only this property will be stored in the Cache. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.JSONFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, dataKey?: string); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - /** - * Called at the end of the load process, after the Loader has finished all files in its queue. - */ - onLoadComplete(): void; - - } - - /** - * A single JSON based Texture Atlas File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#atlas method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlas. - * - * https://www.codeandweb.com/texturepacker/tutorials/how-to-create-sprite-sheets-for-phaser3?source=photonstorm - */ - class AsepriteFile extends Phaser.Loader.MultiFile { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param textureURL The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param atlasURL The absolute or relative URL to load the texture atlas json data file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, a well formed JSON object. - * @param textureXhrSettings An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. - * @param atlasXhrSettings An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AsepriteFileConfig, textureURL?: string | string[], atlasURL?: object | string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - /** - * A single JSON based Texture Atlas File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#atlas method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlas. - * - * https://www.codeandweb.com/texturepacker/tutorials/how-to-create-sprite-sheets-for-phaser3?source=photonstorm - */ - class AtlasJSONFile extends Phaser.Loader.MultiFile { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param textureURL The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param atlasURL The absolute or relative URL to load the texture atlas json data file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, a well formed JSON object. - * @param textureXhrSettings An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. - * @param atlasXhrSettings An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AtlasJSONFileConfig, textureURL?: string | string[], atlasURL?: object | string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - /** - * A single XML based Texture Atlas File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#atlasXML method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlasXML. - */ - class AtlasXMLFile extends Phaser.Loader.MultiFile { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param textureURL The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param atlasURL The absolute or relative URL to load the texture atlas xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param textureXhrSettings An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. - * @param atlasXhrSettings An XHR Settings configuration object for the atlas xml file. Used in replacement of the Loaders default XHR Settings. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AtlasXMLFileConfig, textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - /** - * A single Audio File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#audio method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audio. - */ - class AudioFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param urlConfig The absolute or relative URL to load this file from in a config object. - * @param xhrSettings Extra XHR Settings specifically for this file. - * @param audioContext The AudioContext this file will use to process itself. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AudioFileConfig, urlConfig?: any, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, audioContext?: AudioContext); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - /** - * An Audio Sprite File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#audioSprite method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audioSprite. - */ - class AudioSpriteFile extends Phaser.Loader.MultiFile { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param jsonURL The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. - * @param audioURL The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. - * @param audioConfig The audio configuration options. - * @param audioXhrSettings An XHR Settings configuration object for the audio file. Used in replacement of the Loaders default XHR Settings. - * @param jsonXhrSettings An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AudioSpriteFileConfig, jsonURL: string, audioURL?: Object, audioConfig?: any, audioXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, jsonXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Called by each File when it finishes loading. - * @param file The File that has completed processing. - */ - onFileComplete(file: Phaser.Loader.File): void; - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - /** - * A single Binary File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#binary method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#binary. - */ - class BinaryFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". - * @param xhrSettings Extra XHR Settings specifically for this file. - * @param dataType Optional type to cast the binary file to once loaded. For example, `Uint8Array`. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.BinaryFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, dataType?: any); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - /** - * A single Bitmap Font based File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#bitmapFont method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#bitmapFont. - */ - class BitmapFontFile extends Phaser.Loader.MultiFile { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param textureURL The absolute or relative URL to load the font image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param fontDataURL The absolute or relative URL to load the font xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param textureXhrSettings An XHR Settings configuration object for the font image file. Used in replacement of the Loaders default XHR Settings. - * @param fontDataXhrSettings An XHR Settings configuration object for the font data xml file. Used in replacement of the Loaders default XHR Settings. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.BitmapFontFileConfig, textureURL?: string | string[], fontDataURL?: string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, fontDataXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - /** - * A single CSS File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#css method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#css. - */ - class CSSFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.CSSFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - /** - * A single GLSL File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#glsl method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#glsl. - */ - class GLSLFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param shaderType The type of shader. Either `fragment` for a fragment shader, or `vertex` for a vertex shader. This is ignored if you load a shader bundle. Default 'fragment'. - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.GLSLFileConfig, url?: string, shaderType?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - /** - * Returns the name of the shader from the header block. - * @param headerSource The header data. - */ - getShaderName(headerSource: string[]): string; - - /** - * Returns the type of the shader from the header block. - * @param headerSource The header data. - */ - getShaderType(headerSource: string[]): string; - - /** - * Returns the shader uniforms from the header block. - * @param headerSource The header data. - */ - getShaderUniforms(headerSource: string[]): any; - - } - - /** - * A single Audio File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#audio method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audio. - */ - class HTML5AudioFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param urlConfig The absolute or relative URL to load this file from. - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AudioFileConfig, urlConfig?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Called when the file finishes loading. - */ - onLoad(): void; - - /** - * Called if the file errors while loading. - */ - onError(): void; - - /** - * Called during the file load progress. Is sent a DOM ProgressEvent. - */ - onProgress(): void; - - /** - * Called by the Loader, starts the actual file downloading. - * During the load the methods onLoad, onError and onProgress are called, based on the XHR events. - * You shouldn't normally call this method directly, it's meant to be invoked by the Loader. - */ - load(): void; - - } - - /** - * A single HTML File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#html method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#html. - */ - class HTMLFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.html`, i.e. if `key` was "alien" then the URL will be "alien.html". - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.HTMLFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - /** - * A single HTML File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#htmlTexture method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#htmlTexture. - */ - class HTMLTextureFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param width The width of the texture the HTML will be rendered to. - * @param height The height of the texture the HTML will be rendered to. - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.HTMLTextureFileConfig, url?: string, width?: number, height?: number, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - /** - * A single Image File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#image method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#image. - */ - class ImageFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param xhrSettings Extra XHR Settings specifically for this file. - * @param frameConfig The frame configuration object. Only provided for, and used by, Sprite Sheets. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.ImageFileConfig, url?: string | string[], xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, frameConfig?: Phaser.Types.Loader.FileTypes.ImageFrameConfig); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - /** - * A single JSON File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#json method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#json. - */ - class JSONFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, can be a fully formed JSON Object. - * @param xhrSettings Extra XHR Settings specifically for this file. - * @param dataKey When the JSON file loads only this property will be stored in the Cache. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.JSONFileConfig, url?: object | string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, dataKey?: string); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - /** - * A single Multi Texture Atlas File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#multiatlas method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#multiatlas. - */ - class MultiAtlasFile extends Phaser.Loader.MultiFile { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key of the file. Must be unique within both the Loader and the Texture Manager. Or a config object. - * @param atlasURL The absolute or relative URL to load the multi atlas json file from. - * @param path Optional path to use when loading the textures defined in the atlas data. - * @param baseURL Optional Base URL to use when loading the textures defined in the atlas data. - * @param atlasXhrSettings Extra XHR Settings specifically for the atlas json file. - * @param textureXhrSettings Extra XHR Settings specifically for the texture files. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.MultiAtlasFileConfig, atlasURL?: string, path?: string, baseURL?: string, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Called by each File when it finishes loading. - * @param file The File that has completed processing. - */ - onFileComplete(file: Phaser.Loader.File): void; - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - /** - * A Multi Script File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#scripts method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#scripts. - */ - class MultiScriptFile extends Phaser.Loader.MultiFile { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url An array of absolute or relative URLs to load the script files from. They are processed in the order given in the array. - * @param xhrSettings An XHR Settings configuration object for the script files. Used in replacement of the Loaders default XHR Settings. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.MultiScriptFileConfig, url?: string[], xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - /** - * A single Wavefront OBJ File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#obj method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#obj. - */ - class OBJFile extends Phaser.Loader.MultiFile { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param objURL The absolute or relative URL to load the obj file from. If undefined or `null` it will be set to `.obj`, i.e. if `key` was "alien" then the URL will be "alien.obj". - * @param matURL The absolute or relative URL to load the material file from. If undefined or `null` it will be set to `.mat`, i.e. if `key` was "alien" then the URL will be "alien.mat". - * @param flipUV Flip the UV coordinates stored in the model data? - * @param xhrSettings Extra XHR Settings specifically for these files. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.OBJFileConfig, objURL?: string, matURL?: string, flipUV?: boolean, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - /** - * A single JSON Pack File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#pack method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#pack. - */ - class PackFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param xhrSettings Extra XHR Settings specifically for this file. - * @param dataKey When the JSON file loads only this property will be stored in the Cache. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.PackFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, dataKey?: string); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - /** - * A single Plugin Script File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#plugin method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#plugin. - */ - class PluginFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param start Automatically start the plugin after loading? Default false. - * @param mapping If this plugin is to be injected into the Scene, this is the property key used. - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.PluginFileConfig, url?: string, start?: boolean, mapping?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - /** - * An external Scene JavaScript File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#sceneFile method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#sceneFile. - */ - class SceneFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.SceneFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - /** - * A single Scene Plugin Script File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#scenePlugin method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#scenePlugin. - */ - class ScenePluginFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param systemKey If this plugin is to be added to Scene.Systems, this is the property key for it. - * @param sceneKey If this plugin is to be added to the Scene, this is the property key for it. - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.ScenePluginFileConfig, url?: string, systemKey?: string, sceneKey?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - /** - * A single Script File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#script method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#script. - */ - class ScriptFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.ScriptFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - /** - * A single Sprite Sheet Image File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#spritesheet method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#spritesheet. - */ - class SpriteSheetFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param frameConfig The frame configuration object. - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.SpriteSheetFileConfig, url?: string | string[], frameConfig?: Phaser.Types.Loader.FileTypes.ImageFrameConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - /** - * A single SVG File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#svg method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#svg. - */ - class SVGFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". - * @param svgConfig The svg size configuration object. - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.SVGFileConfig, url?: string, svgConfig?: Phaser.Types.Loader.FileTypes.SVGSizeConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - /** - * A single Text File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#text method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#text. - */ - class TextFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.TextFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - /** - * A single Tilemap CSV File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapCSV method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapCSV. - */ - class TilemapCSVFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.csv`, i.e. if `key` was "alien" then the URL will be "alien.csv". - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.TilemapCSVFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - /** - * A single Impact.js Tilemap JSON File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapImpact method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapImpact. - */ - class TilemapImpactFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.TilemapImpactFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - /** - * A single Tiled Tilemap JSON File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapTiledJSON method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapTiledJSON. - */ - class TilemapJSONFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, a well formed JSON object. - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.TilemapJSONFileConfig, url?: object | string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - /** - * A single text file based Unity Texture Atlas File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#unityAtlas method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#unityAtlas. - */ - class UnityAtlasFile extends Phaser.Loader.MultiFile { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param textureURL The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param atlasURL The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param textureXhrSettings An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. - * @param atlasXhrSettings An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.UnityAtlasFileConfig, textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - /** - * A single Video File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#video method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#video. - */ - class VideoFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param urlConfig The absolute or relative URL to load this file from in a config object. - * @param loadEvent The load event to listen for when _not_ loading as a blob. Either 'loadeddata', 'canplay' or 'canplaythrough'. - * @param asBlob Load the video as a data blob, or via the Video element? - * @param noAudio Does the video have an audio track? If not you can enable auto-playing on it. - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.VideoFileConfig, urlConfig?: any, loadEvent?: string, asBlob?: boolean, noAudio?: boolean, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - /** - * Called by the Loader, starts the actual file downloading. - * During the load the methods onLoad, onError and onProgress are called, based on the XHR events. - * You shouldn't normally call this method directly, it's meant to be invoked by the Loader. - */ - load(): void; - - } - - /** - * A single XML File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#xml method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#xml. - */ - class XMLFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.XMLFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - } - namespace FileTypesManager { /** * Static method called when a LoaderPlugin is created. @@ -53853,6 +52733,335 @@ declare namespace Phaser { */ constructor(scene: Phaser.Scene); + /** + * The Scene which owns this Loader instance. + */ + scene: Phaser.Scene; + + /** + * A reference to the Scene Systems. + */ + systems: Phaser.Scenes.Systems; + + /** + * A reference to the global Cache Manager. + */ + cacheManager: Phaser.Cache.CacheManager; + + /** + * A reference to the global Texture Manager. + */ + textureManager: Phaser.Textures.TextureManager; + + /** + * A reference to the global Scene Manager. + */ + protected sceneManager: Phaser.Scenes.SceneManager; + + /** + * An optional prefix that is automatically prepended to the start of every file key. + * If prefix was `MENU.` and you load an image with the key 'Background' the resulting key would be `MENU.Background`. + * You can set this directly, or call `Loader.setPrefix()`. It will then affect every file added to the Loader + * from that point on. It does _not_ change any file already in the load queue. + */ + prefix: string; + + /** + * The value of `path`, if set, is placed before any _relative_ file path given. For example: + * + * ```javascript + * this.load.path = "images/sprites/"; + * this.load.image("ball", "ball.png"); + * this.load.image("tree", "level1/oaktree.png"); + * this.load.image("boom", "http://server.com/explode.png"); + * ``` + * + * Would load the `ball` file from `images/sprites/ball.png` and the tree from + * `images/sprites/level1/oaktree.png` but the file `boom` would load from the URL + * given as it's an absolute URL. + * + * Please note that the path is added before the filename but *after* the baseURL (if set.) + * + * If you set this property directly then it _must_ end with a "/". Alternatively, call `setPath()` and it'll do it for you. + */ + path: string; + + /** + * If you want to append a URL before the path of any asset you can set this here. + * + * Useful if allowing the asset base url to be configured outside of the game code. + * + * If you set this property directly then it _must_ end with a "/". Alternatively, call `setBaseURL()` and it'll do it for you. + */ + baseURL: string; + + /** + * The number of concurrent / parallel resources to try and fetch at once. + * + * Old browsers limit 6 requests per domain; modern ones, especially those with HTTP/2 don't limit it at all. + * + * The default is 32 but you can change this in your Game Config, or by changing this property before the Loader starts. + */ + maxParallelDownloads: number; + + /** + * xhr specific global settings (can be overridden on a per-file basis) + */ + xhr: Phaser.Types.Loader.XHRSettingsObject; + + /** + * The crossOrigin value applied to loaded images. Very often this needs to be set to 'anonymous'. + */ + crossOrigin: string; + + /** + * The total number of files to load. It may not always be accurate because you may add to the Loader during the process + * of loading, especially if you load a Pack File. Therefore this value can change, but in most cases remains static. + */ + totalToLoad: number; + + /** + * The progress of the current load queue, as a float value between 0 and 1. + * This is updated automatically as files complete loading. + * Note that it is possible for this value to go down again if you add content to the current load queue during a load. + */ + progress: number; + + /** + * Files are placed in this Set when they're added to the Loader via `addFile`. + * + * They are moved to the `inflight` Set when they start loading, and assuming a successful + * load, to the `queue` Set for further processing. + * + * By the end of the load process this Set will be empty. + */ + list: Phaser.Structs.Set; + + /** + * Files are stored in this Set while they're in the process of being loaded. + * + * Upon a successful load they are moved to the `queue` Set. + * + * By the end of the load process this Set will be empty. + */ + inflight: Phaser.Structs.Set; + + /** + * Files are stored in this Set while they're being processed. + * + * If the process is successful they are moved to their final destination, which could be + * a Cache or the Texture Manager. + * + * At the end of the load process this Set will be empty. + */ + queue: Phaser.Structs.Set; + + /** + * The total number of files that failed to load during the most recent load. + * This value is reset when you call `Loader.start`. + */ + totalFailed: number; + + /** + * The total number of files that successfully loaded during the most recent load. + * This value is reset when you call `Loader.start`. + */ + totalComplete: number; + + /** + * The current state of the Loader. + */ + readonly state: number; + + /** + * If you want to append a URL before the path of any asset you can set this here. + * + * Useful if allowing the asset base url to be configured outside of the game code. + * + * Once a base URL is set it will affect every file loaded by the Loader from that point on. It does _not_ change any + * file _already_ being loaded. To reset it, call this method with no arguments. + * @param url The URL to use. Leave empty to reset. + */ + setBaseURL(url?: string): this; + + /** + * The value of `path`, if set, is placed before any _relative_ file path given. For example: + * + * ```javascript + * this.load.setPath("images/sprites/"); + * this.load.image("ball", "ball.png"); + * this.load.image("tree", "level1/oaktree.png"); + * this.load.image("boom", "http://server.com/explode.png"); + * ``` + * + * Would load the `ball` file from `images/sprites/ball.png` and the tree from + * `images/sprites/level1/oaktree.png` but the file `boom` would load from the URL + * given as it's an absolute URL. + * + * Please note that the path is added before the filename but *after* the baseURL (if set.) + * + * Once a path is set it will then affect every file added to the Loader from that point on. It does _not_ change any + * file _already_ in the load queue. To reset it, call this method with no arguments. + * @param path The path to use. Leave empty to reset. + */ + setPath(path?: string): this; + + /** + * An optional prefix that is automatically prepended to the start of every file key. + * + * If prefix was `MENU.` and you load an image with the key 'Background' the resulting key would be `MENU.Background`. + * + * Once a prefix is set it will then affect every file added to the Loader from that point on. It does _not_ change any + * file _already_ in the load queue. To reset it, call this method with no arguments. + * @param prefix The prefix to use. Leave empty to reset. + */ + setPrefix(prefix?: string): this; + + /** + * Sets the Cross Origin Resource Sharing value used when loading files. + * + * Files can override this value on a per-file basis by specifying an alternative `crossOrigin` value in their file config. + * + * Once CORs is set it will then affect every file loaded by the Loader from that point on, as long as they don't have + * their own CORs setting. To reset it, call this method with no arguments. + * + * For more details about CORs see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS + * @param crossOrigin The value to use for the `crossOrigin` property in the load request. + */ + setCORS(crossOrigin?: string): this; + + /** + * Adds a file, or array of files, into the load queue. + * + * The file must be an instance of `Phaser.Loader.File`, or a class that extends it. The Loader will check that the key + * used by the file won't conflict with any other key either in the loader, the inflight queue or the target cache. + * If allowed it will then add the file into the pending list, read for the load to start. Or, if the load has already + * started, ready for the next batch of files to be pulled from the list to the inflight queue. + * + * You should not normally call this method directly, but rather use one of the Loader methods like `image` or `atlas`, + * however you can call this as long as the file given to it is well formed. + * @param file The file, or array of files, to be added to the load queue. + */ + addFile(file: Phaser.Loader.File | Phaser.Loader.File[]): void; + + /** + * Checks the key and type of the given file to see if it will conflict with anything already + * in a Cache, the Texture Manager, or the list or inflight queues. + * @param file The file to check the key of. + */ + keyExists(file: Phaser.Loader.File): boolean; + + /** + * Takes a well formed, fully parsed pack file object and adds its entries into the load queue. Usually you do not call + * this method directly, but instead use `Loader.pack` and supply a path to a JSON file that holds the + * pack data. However, if you've got the data prepared you can pass it to this method. + * + * You can also provide an optional key. If you do then it will only add the entries from that part of the pack into + * to the load queue. If not specified it will add all entries it finds. For more details about the pack file format + * see the `LoaderPlugin.pack` method. + * @param pack The Pack File data to be parsed and each entry of it to added to the load queue. + * @param packKey An optional key to use from the pack file data. + */ + addPack(pack: any, packKey?: string): boolean; + + /** + * Is the Loader actively loading, or processing loaded files? + */ + isLoading(): boolean; + + /** + * Is the Loader ready to start a new load? + */ + isReady(): boolean; + + /** + * Starts the Loader running. This will reset the progress and totals and then emit a `start` event. + * If there is nothing in the queue the Loader will immediately complete, otherwise it will start + * loading the first batch of files. + * + * The Loader is started automatically if the queue is populated within your Scenes `preload` method. + * + * However, outside of this, you need to call this method to start it. + * + * If the Loader is already running this method will simply return. + */ + start(): void; + + /** + * Called automatically during the load process. + * It updates the `progress` value and then emits a progress event, which you can use to + * display a loading bar in your game. + */ + updateProgress(): void; + + /** + * Called automatically during the load process. + */ + update(): void; + + /** + * An internal method called automatically by the XHRLoader belong to a File. + * + * This method will remove the given file from the inflight Set and update the load progress. + * If the file was successful its `onProcess` method is called, otherwise it is added to the delete queue. + * @param file The File that just finished loading, or errored during load. + * @param success `true` if the file loaded successfully, otherwise `false`. + */ + nextFile(file: Phaser.Loader.File, success: boolean): void; + + /** + * An internal method that is called automatically by the File when it has finished processing. + * + * If the process was successful, and the File isn't part of a MultiFile, its `addToCache` method is called. + * + * It this then removed from the queue. If there are no more files to load `loadComplete` is called. + * @param file The file that has finished processing. + */ + fileProcessComplete(file: Phaser.Loader.File): void; + + /** + * Called at the end when the load queue is exhausted and all files have either loaded or errored. + * By this point every loaded file will now be in its associated cache and ready for use. + * + * Also clears down the Sets, puts progress to 1 and clears the deletion queue. + */ + loadComplete(): void; + + /** + * Adds a File into the pending-deletion queue. + * @param file The File to be queued for deletion when the Loader completes. + */ + flagForRemoval(file: Phaser.Loader.File): void; + + /** + * Converts the given JSON data into a file that the browser then prompts you to download so you can save it locally. + * + * The data must be well formed JSON and ready-parsed, not a JavaScript object. + * @param data The JSON data, ready parsed. + * @param filename The name to save the JSON file as. Default file.json. + */ + saveJSON(data: any, filename?: string): this; + + /** + * Causes the browser to save the given data as a file to its default Downloads folder. + * + * Creates a DOM level anchor link, assigns it as being a `download` anchor, sets the href + * to be an ObjectURL based on the given data, and then invokes a click event. + * @param data The data to be saved. Will be passed through URL.createObjectURL. + * @param filename The filename to save the file as. Default file.json. + * @param filetype The file type to use when saving the file. Defaults to JSON. Default application/json. + */ + save(data: any, filename?: string, filetype?: string): this; + + /** + * Resets the Loader. + * + * This will clear all lists and reset the base URL, path and prefix. + * + * Warning: If the Loader is currently downloading files, or has files in its queue, they will be aborted. + */ + reset(): void; + /** * Adds an Animation JSON Data file, or array of Animation JSON files, to the current load queue. * @@ -55384,6 +54593,118 @@ declare namespace Phaser { */ plugin(key: string | Phaser.Types.Loader.FileTypes.PluginFileConfig | Phaser.Types.Loader.FileTypes.PluginFileConfig[], url?: string | Function, start?: boolean, mapping?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; + /** + * Adds an SVG File, or array of SVG Files, to the current load queue. When the files are loaded they + * will be rendered to bitmap textures and stored in the Texture Manager. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg' + * }); + * ``` + * + * See the documentation for `Phaser.Types.Loader.FileTypes.SVGFileConfig` for more details. + * + * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: + * + * ```javascript + * this.load.svg('morty', 'images/Morty.svg'); + * // and later in your game ... + * this.add.image(x, y, 'morty'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.html". It will always add `.html` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * You can optionally pass an SVG Resize Configuration object when you load an SVG file. By default the SVG will be rendered to a texture + * at the same size defined in the SVG file attributes. However, this isn't always desirable. You may wish to resize the SVG (either down + * or up) to improve texture clarity, or reduce texture memory consumption. You can either specify an exact width and height to resize + * the SVG to: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg', { width: 300, height: 600 }); + * } + * ``` + * + * Or when using a configuration object: + * + * ```javascript + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg', + * svgConfig: { + * width: 300, + * height: 600 + * } + * }); + * ``` + * + * Alternatively, you can just provide a scale factor instead: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg', { scale: 2.5 }); + * } + * ``` + * + * Or when using a configuration object: + * + * ```javascript + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg', + * svgConfig: { + * scale: 2.5 + * } + * }); + * ``` + * + * If scale, width and height values are all given, the scale has priority and the width and height values are ignored. + * + * Note: The ability to load this type of file will only be available if the SVG File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * @param key The key to use for this file, or a file configuration object, or array of them. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". + * @param svgConfig The svg size configuration object. + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + svg(key: string | Phaser.Types.Loader.FileTypes.SVGFileConfig | Phaser.Types.Loader.FileTypes.SVGFileConfig[], url?: string, svgConfig?: Phaser.Types.Loader.FileTypes.SVGSizeConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; + /** * Adds an external Scene file, or array of Scene files, to the current load queue. * @@ -55683,118 +55004,6 @@ declare namespace Phaser { */ spritesheet(key: string | Phaser.Types.Loader.FileTypes.SpriteSheetFileConfig | Phaser.Types.Loader.FileTypes.SpriteSheetFileConfig[], url?: string, frameConfig?: Phaser.Types.Loader.FileTypes.ImageFrameConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; - /** - * Adds an SVG File, or array of SVG Files, to the current load queue. When the files are loaded they - * will be rendered to bitmap textures and stored in the Texture Manager. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.svg('morty', 'images/Morty.svg'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.svg({ - * key: 'morty', - * url: 'images/Morty.svg' - * }); - * ``` - * - * See the documentation for `Phaser.Types.Loader.FileTypes.SVGFileConfig` for more details. - * - * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: - * - * ```javascript - * this.load.svg('morty', 'images/Morty.svg'); - * // and later in your game ... - * this.add.image(x, y, 'morty'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use to retrieve the image from the Texture Manager. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.html". It will always add `.html` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * You can optionally pass an SVG Resize Configuration object when you load an SVG file. By default the SVG will be rendered to a texture - * at the same size defined in the SVG file attributes. However, this isn't always desirable. You may wish to resize the SVG (either down - * or up) to improve texture clarity, or reduce texture memory consumption. You can either specify an exact width and height to resize - * the SVG to: - * - * ```javascript - * function preload () - * { - * this.load.svg('morty', 'images/Morty.svg', { width: 300, height: 600 }); - * } - * ``` - * - * Or when using a configuration object: - * - * ```javascript - * this.load.svg({ - * key: 'morty', - * url: 'images/Morty.svg', - * svgConfig: { - * width: 300, - * height: 600 - * } - * }); - * ``` - * - * Alternatively, you can just provide a scale factor instead: - * - * ```javascript - * function preload () - * { - * this.load.svg('morty', 'images/Morty.svg', { scale: 2.5 }); - * } - * ``` - * - * Or when using a configuration object: - * - * ```javascript - * this.load.svg({ - * key: 'morty', - * url: 'images/Morty.svg', - * svgConfig: { - * scale: 2.5 - * } - * }); - * ``` - * - * If scale, width and height values are all given, the scale has priority and the width and height values are ignored. - * - * Note: The ability to load this type of file will only be available if the SVG File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * @param key The key to use for this file, or a file configuration object, or array of them. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". - * @param svgConfig The svg size configuration object. - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - svg(key: string | Phaser.Types.Loader.FileTypes.SVGFileConfig | Phaser.Types.Loader.FileTypes.SVGFileConfig[], url?: string, svgConfig?: Phaser.Types.Loader.FileTypes.SVGSizeConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; - /** * Adds a Text file, or array of Text files, to the current load queue. * @@ -56264,335 +55473,6 @@ declare namespace Phaser { */ xml(key: string | Phaser.Types.Loader.FileTypes.XMLFileConfig | Phaser.Types.Loader.FileTypes.XMLFileConfig[], url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; - /** - * The Scene which owns this Loader instance. - */ - scene: Phaser.Scene; - - /** - * A reference to the Scene Systems. - */ - systems: Phaser.Scenes.Systems; - - /** - * A reference to the global Cache Manager. - */ - cacheManager: Phaser.Cache.CacheManager; - - /** - * A reference to the global Texture Manager. - */ - textureManager: Phaser.Textures.TextureManager; - - /** - * A reference to the global Scene Manager. - */ - protected sceneManager: Phaser.Scenes.SceneManager; - - /** - * An optional prefix that is automatically prepended to the start of every file key. - * If prefix was `MENU.` and you load an image with the key 'Background' the resulting key would be `MENU.Background`. - * You can set this directly, or call `Loader.setPrefix()`. It will then affect every file added to the Loader - * from that point on. It does _not_ change any file already in the load queue. - */ - prefix: string; - - /** - * The value of `path`, if set, is placed before any _relative_ file path given. For example: - * - * ```javascript - * this.load.path = "images/sprites/"; - * this.load.image("ball", "ball.png"); - * this.load.image("tree", "level1/oaktree.png"); - * this.load.image("boom", "http://server.com/explode.png"); - * ``` - * - * Would load the `ball` file from `images/sprites/ball.png` and the tree from - * `images/sprites/level1/oaktree.png` but the file `boom` would load from the URL - * given as it's an absolute URL. - * - * Please note that the path is added before the filename but *after* the baseURL (if set.) - * - * If you set this property directly then it _must_ end with a "/". Alternatively, call `setPath()` and it'll do it for you. - */ - path: string; - - /** - * If you want to append a URL before the path of any asset you can set this here. - * - * Useful if allowing the asset base url to be configured outside of the game code. - * - * If you set this property directly then it _must_ end with a "/". Alternatively, call `setBaseURL()` and it'll do it for you. - */ - baseURL: string; - - /** - * The number of concurrent / parallel resources to try and fetch at once. - * - * Old browsers limit 6 requests per domain; modern ones, especially those with HTTP/2 don't limit it at all. - * - * The default is 32 but you can change this in your Game Config, or by changing this property before the Loader starts. - */ - maxParallelDownloads: number; - - /** - * xhr specific global settings (can be overridden on a per-file basis) - */ - xhr: Phaser.Types.Loader.XHRSettingsObject; - - /** - * The crossOrigin value applied to loaded images. Very often this needs to be set to 'anonymous'. - */ - crossOrigin: string; - - /** - * The total number of files to load. It may not always be accurate because you may add to the Loader during the process - * of loading, especially if you load a Pack File. Therefore this value can change, but in most cases remains static. - */ - totalToLoad: number; - - /** - * The progress of the current load queue, as a float value between 0 and 1. - * This is updated automatically as files complete loading. - * Note that it is possible for this value to go down again if you add content to the current load queue during a load. - */ - progress: number; - - /** - * Files are placed in this Set when they're added to the Loader via `addFile`. - * - * They are moved to the `inflight` Set when they start loading, and assuming a successful - * load, to the `queue` Set for further processing. - * - * By the end of the load process this Set will be empty. - */ - list: Phaser.Structs.Set; - - /** - * Files are stored in this Set while they're in the process of being loaded. - * - * Upon a successful load they are moved to the `queue` Set. - * - * By the end of the load process this Set will be empty. - */ - inflight: Phaser.Structs.Set; - - /** - * Files are stored in this Set while they're being processed. - * - * If the process is successful they are moved to their final destination, which could be - * a Cache or the Texture Manager. - * - * At the end of the load process this Set will be empty. - */ - queue: Phaser.Structs.Set; - - /** - * The total number of files that failed to load during the most recent load. - * This value is reset when you call `Loader.start`. - */ - totalFailed: number; - - /** - * The total number of files that successfully loaded during the most recent load. - * This value is reset when you call `Loader.start`. - */ - totalComplete: number; - - /** - * The current state of the Loader. - */ - readonly state: number; - - /** - * If you want to append a URL before the path of any asset you can set this here. - * - * Useful if allowing the asset base url to be configured outside of the game code. - * - * Once a base URL is set it will affect every file loaded by the Loader from that point on. It does _not_ change any - * file _already_ being loaded. To reset it, call this method with no arguments. - * @param url The URL to use. Leave empty to reset. - */ - setBaseURL(url?: string): this; - - /** - * The value of `path`, if set, is placed before any _relative_ file path given. For example: - * - * ```javascript - * this.load.setPath("images/sprites/"); - * this.load.image("ball", "ball.png"); - * this.load.image("tree", "level1/oaktree.png"); - * this.load.image("boom", "http://server.com/explode.png"); - * ``` - * - * Would load the `ball` file from `images/sprites/ball.png` and the tree from - * `images/sprites/level1/oaktree.png` but the file `boom` would load from the URL - * given as it's an absolute URL. - * - * Please note that the path is added before the filename but *after* the baseURL (if set.) - * - * Once a path is set it will then affect every file added to the Loader from that point on. It does _not_ change any - * file _already_ in the load queue. To reset it, call this method with no arguments. - * @param path The path to use. Leave empty to reset. - */ - setPath(path?: string): this; - - /** - * An optional prefix that is automatically prepended to the start of every file key. - * - * If prefix was `MENU.` and you load an image with the key 'Background' the resulting key would be `MENU.Background`. - * - * Once a prefix is set it will then affect every file added to the Loader from that point on. It does _not_ change any - * file _already_ in the load queue. To reset it, call this method with no arguments. - * @param prefix The prefix to use. Leave empty to reset. - */ - setPrefix(prefix?: string): this; - - /** - * Sets the Cross Origin Resource Sharing value used when loading files. - * - * Files can override this value on a per-file basis by specifying an alternative `crossOrigin` value in their file config. - * - * Once CORs is set it will then affect every file loaded by the Loader from that point on, as long as they don't have - * their own CORs setting. To reset it, call this method with no arguments. - * - * For more details about CORs see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS - * @param crossOrigin The value to use for the `crossOrigin` property in the load request. - */ - setCORS(crossOrigin?: string): this; - - /** - * Adds a file, or array of files, into the load queue. - * - * The file must be an instance of `Phaser.Loader.File`, or a class that extends it. The Loader will check that the key - * used by the file won't conflict with any other key either in the loader, the inflight queue or the target cache. - * If allowed it will then add the file into the pending list, read for the load to start. Or, if the load has already - * started, ready for the next batch of files to be pulled from the list to the inflight queue. - * - * You should not normally call this method directly, but rather use one of the Loader methods like `image` or `atlas`, - * however you can call this as long as the file given to it is well formed. - * @param file The file, or array of files, to be added to the load queue. - */ - addFile(file: Phaser.Loader.File | Phaser.Loader.File[]): void; - - /** - * Checks the key and type of the given file to see if it will conflict with anything already - * in a Cache, the Texture Manager, or the list or inflight queues. - * @param file The file to check the key of. - */ - keyExists(file: Phaser.Loader.File): boolean; - - /** - * Takes a well formed, fully parsed pack file object and adds its entries into the load queue. Usually you do not call - * this method directly, but instead use `Loader.pack` and supply a path to a JSON file that holds the - * pack data. However, if you've got the data prepared you can pass it to this method. - * - * You can also provide an optional key. If you do then it will only add the entries from that part of the pack into - * to the load queue. If not specified it will add all entries it finds. For more details about the pack file format - * see the `LoaderPlugin.pack` method. - * @param pack The Pack File data to be parsed and each entry of it to added to the load queue. - * @param packKey An optional key to use from the pack file data. - */ - addPack(pack: any, packKey?: string): boolean; - - /** - * Is the Loader actively loading, or processing loaded files? - */ - isLoading(): boolean; - - /** - * Is the Loader ready to start a new load? - */ - isReady(): boolean; - - /** - * Starts the Loader running. This will reset the progress and totals and then emit a `start` event. - * If there is nothing in the queue the Loader will immediately complete, otherwise it will start - * loading the first batch of files. - * - * The Loader is started automatically if the queue is populated within your Scenes `preload` method. - * - * However, outside of this, you need to call this method to start it. - * - * If the Loader is already running this method will simply return. - */ - start(): void; - - /** - * Called automatically during the load process. - * It updates the `progress` value and then emits a progress event, which you can use to - * display a loading bar in your game. - */ - updateProgress(): void; - - /** - * Called automatically during the load process. - */ - update(): void; - - /** - * An internal method called automatically by the XHRLoader belong to a File. - * - * This method will remove the given file from the inflight Set and update the load progress. - * If the file was successful its `onProcess` method is called, otherwise it is added to the delete queue. - * @param file The File that just finished loading, or errored during load. - * @param success `true` if the file loaded successfully, otherwise `false`. - */ - nextFile(file: Phaser.Loader.File, success: boolean): void; - - /** - * An internal method that is called automatically by the File when it has finished processing. - * - * If the process was successful, and the File isn't part of a MultiFile, its `addToCache` method is called. - * - * It this then removed from the queue. If there are no more files to load `loadComplete` is called. - * @param file The file that has finished processing. - */ - fileProcessComplete(file: Phaser.Loader.File): void; - - /** - * Called at the end when the load queue is exhausted and all files have either loaded or errored. - * By this point every loaded file will now be in its associated cache and ready for use. - * - * Also clears down the Sets, puts progress to 1 and clears the deletion queue. - */ - loadComplete(): void; - - /** - * Adds a File into the pending-deletion queue. - * @param file The File to be queued for deletion when the Loader completes. - */ - flagForRemoval(file: Phaser.Loader.File): void; - - /** - * Converts the given JSON data into a file that the browser then prompts you to download so you can save it locally. - * - * The data must be well formed JSON and ready-parsed, not a JavaScript object. - * @param data The JSON data, ready parsed. - * @param filename The name to save the JSON file as. Default file.json. - */ - saveJSON(data: any, filename?: string): this; - - /** - * Causes the browser to save the given data as a file to its default Downloads folder. - * - * Creates a DOM level anchor link, assigns it as being a `download` anchor, sets the href - * to be an ObjectURL based on the given data, and then invokes a click event. - * @param data The data to be saved. Will be passed through URL.createObjectURL. - * @param filename The filename to save the file as. Default file.json. - * @param filetype The file type to use when saving the file. Defaults to JSON. Default application/json. - */ - save(data: any, filename?: string, filetype?: string): this; - - /** - * Resets the Loader. - * - * This will clear all lists and reset the base URL, path and prefix. - * - * Warning: If the Loader is currently downloading files, or has files in its queue, they will be aborted. - */ - reset(): void; - } /** @@ -56724,129 +55604,1136 @@ declare namespace Phaser { */ function XHRSettings(responseType?: XMLHttpRequestResponseType, async?: boolean, user?: string, password?: string, timeout?: number, withCredentials?: boolean): Phaser.Types.Loader.XHRSettingsObject; - } + /** + * The Loader is idle. + */ + var LOADER_IDLE: number; - namespace Math { - namespace Angle { - /** - * Find the angle of a segment from (x1, y1) -> (x2, y2). - * @param x1 The x coordinate of the first point. - * @param y1 The y coordinate of the first point. - * @param x2 The x coordinate of the second point. - * @param y2 The y coordinate of the second point. - */ - function Between(x1: number, y1: number, x2: number, y2: number): number; + /** + * The Loader is actively loading. + */ + var LOADER_LOADING: number; + /** + * The Loader is processing files is has loaded. + */ + var LOADER_PROCESSING: number; + + /** + * The Loader has completed loading and processing. + */ + var LOADER_COMPLETE: number; + + /** + * The Loader is shutting down. + */ + var LOADER_SHUTDOWN: number; + + /** + * The Loader has been destroyed. + */ + var LOADER_DESTROYED: number; + + /** + * File is in the load queue but not yet started + */ + var FILE_PENDING: number; + + /** + * File has been started to load by the loader (onLoad called) + */ + var FILE_LOADING: number; + + /** + * File has loaded successfully, awaiting processing + */ + var FILE_LOADED: number; + + /** + * File failed to load + */ + var FILE_FAILED: number; + + /** + * File is being processed (onProcess callback) + */ + var FILE_PROCESSING: number; + + /** + * The File has errored somehow during processing. + */ + var FILE_ERRORED: number; + + /** + * File has finished processing. + */ + var FILE_COMPLETE: number; + + /** + * File has been destroyed + */ + var FILE_DESTROYED: number; + + /** + * File was populated from local data and doesn't need an HTTP request + */ + var FILE_POPULATED: number; + + namespace Events { /** - * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). + * The Loader Plugin Add File Event. * - * Calculates the angle of the vector from the first point to the second point. - * @param point1 The first point. - * @param point2 The second point. + * This event is dispatched when a new file is successfully added to the Loader and placed into the load queue. + * + * Listen to it from a Scene using: `this.load.on('addfile', listener)`. + * + * If you add lots of files to a Loader from a `preload` method, it will dispatch this event for each one of them. */ - function BetweenPoints(point1: Phaser.Types.Math.Vector2Like, point2: Phaser.Types.Math.Vector2Like): number; + const ADD: any; /** - * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). + * The Loader Plugin Complete Event. * - * The difference between this method and {@link Phaser.Math.Angle.BetweenPoints} is that this assumes the y coordinate - * travels down the screen. - * @param point1 The first point. - * @param point2 The second point. + * This event is dispatched when the Loader has fully processed everything in the load queue. + * By this point every loaded file will now be in its associated cache and ready for use. + * + * Listen to it from a Scene using: `this.load.on('complete', listener)`. */ - function BetweenPointsY(point1: Phaser.Types.Math.Vector2Like, point2: Phaser.Types.Math.Vector2Like): number; + const COMPLETE: any; /** - * Find the angle of a segment from (x1, y1) -> (x2, y2). + * The File Load Complete Event. * - * The difference between this method and {@link Phaser.Math.Angle.Between} is that this assumes the y coordinate - * travels down the screen. - * @param x1 The x coordinate of the first point. - * @param y1 The y coordinate of the first point. - * @param x2 The x coordinate of the second point. - * @param y2 The y coordinate of the second point. + * This event is dispatched by the Loader Plugin when any file in the queue finishes loading. + * + * Listen to it from a Scene using: `this.load.on('filecomplete', listener)`. + * + * You can also listen for the completion of a specific file. See the [FILE_KEY_COMPLETE]{@linkcode Phaser.Loader.Events#event:FILE_KEY_COMPLETE} event. */ - function BetweenY(x1: number, y1: number, x2: number, y2: number): number; + const FILE_COMPLETE: any; /** - * Takes an angle in Phasers default clockwise format and converts it so that - * 0 is North, 90 is West, 180 is South and 270 is East, - * therefore running counter-clockwise instead of clockwise. + * The File Load Complete Event. * - * You can pass in the angle from a Game Object using: + * This event is dispatched by the Loader Plugin when any file in the queue finishes loading. + * + * It uses a special dynamic event name constructed from the key and type of the file. + * + * For example, if you have loaded an `image` with a key of `monster`, you can listen for it + * using the following: * * ```javascript - * var converted = CounterClockwise(gameobject.rotation); + * this.load.on('filecomplete-image-monster', function (key, type, data) { + * // Your handler code + * }); * ``` * - * All values for this function are in radians. - * @param angle The angle to convert, in radians. - */ - function CounterClockwise(angle: number): number; - - /** - * Normalize an angle to the [0, 2pi] range. - * @param angle The angle to normalize, in radians. - */ - function Normalize(angle: number): number; - - /** - * Returns a random angle in the range [-pi, pi]. - */ - function Random(): number; - - /** - * Returns a random angle in the range [-180, 180]. - */ - function RandomDegrees(): number; - - /** - * Reverse the given angle. - * @param angle The angle to reverse, in radians. - */ - function Reverse(angle: number): number; - - /** - * Rotates `currentAngle` towards `targetAngle`, taking the shortest rotation distance. The `lerp` argument is the amount to rotate by in this call. - * @param currentAngle The current angle, in radians. - * @param targetAngle The target angle to rotate to, in radians. - * @param lerp The lerp value to add to the current angle. Default 0.05. - */ - function RotateTo(currentAngle: number, targetAngle: number, lerp?: number): number; - - /** - * Gets the shortest angle between `angle1` and `angle2`. + * Or, if you have loaded a texture `atlas` with a key of `Level1`: * - * Both angles must be in the range -180 to 180, which is the same clamped - * range that `sprite.angle` uses, so you can pass in two sprite angles to - * this method and get the shortest angle back between the two of them. + * ```javascript + * this.load.on('filecomplete-atlas-Level1', function (key, type, data) { + * // Your handler code + * }); + * ``` * - * The angle returned will be in the same range. If the returned angle is - * greater than 0 then it's a counter-clockwise rotation, if < 0 then it's - * a clockwise rotation. - * @param angle1 The first angle in the range -180 to 180. - * @param angle2 The second angle in the range -180 to 180. + * Or, if you have loaded a sprite sheet with a key of `Explosion` and a prefix of `GAMEOVER`: + * + * ```javascript + * this.load.on('filecomplete-spritesheet-GAMEOVERExplosion', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * You can also listen for the generic completion of files. See the [FILE_COMPLETE]{@linkcode Phaser.Loader.Events#event:FILE_COMPLETE} event. */ - function ShortestBetween(angle1: number, angle2: number): number; + const FILE_KEY_COMPLETE: any; /** - * Wrap an angle. + * The File Load Error Event. * - * Wraps the angle to a value in the range of -PI to PI. - * @param angle The angle to wrap, in radians. + * This event is dispatched by the Loader Plugin when a file fails to load. + * + * Listen to it from a Scene using: `this.load.on('loaderror', listener)`. */ - function Wrap(angle: number): number; + const FILE_LOAD_ERROR: any; /** - * Wrap an angle in degrees. + * The File Load Event. * - * Wraps the angle to a value in the range of -180 to 180. - * @param angle The angle to wrap, in degrees. + * This event is dispatched by the Loader Plugin when a file finishes loading, + * but _before_ it is processed and added to the internal Phaser caches. + * + * Listen to it from a Scene using: `this.load.on('load', listener)`. */ - function WrapDegrees(angle: number): number; + const FILE_LOAD: any; + + /** + * The File Load Progress Event. + * + * This event is dispatched by the Loader Plugin during the load of a file, if the browser receives a DOM ProgressEvent and + * the `lengthComputable` event property is true. Depending on the size of the file and browser in use, this may, or may not happen. + * + * Listen to it from a Scene using: `this.load.on('fileprogress', listener)`. + */ + const FILE_PROGRESS: any; + + /** + * The Loader Plugin Post Process Event. + * + * This event is dispatched by the Loader Plugin when the Loader has finished loading everything in the load queue. + * It is dispatched before the internal lists are cleared and each File is destroyed. + * + * Use this hook to perform any last minute processing of files that can only happen once the + * Loader has completed, but prior to it emitting the `complete` event. + * + * Listen to it from a Scene using: `this.load.on('postprocess', listener)`. + */ + const POST_PROCESS: any; + + /** + * The Loader Plugin Progress Event. + * + * This event is dispatched when the Loader updates its load progress, typically as a result of a file having completed loading. + * + * Listen to it from a Scene using: `this.load.on('progress', listener)`. + */ + const PROGRESS: any; + + /** + * The Loader Plugin Start Event. + * + * This event is dispatched when the Loader starts running. At this point load progress is zero. + * + * This event is dispatched even if there aren't any files in the load queue. + * + * Listen to it from a Scene using: `this.load.on('start', listener)`. + */ + const START: any; } + namespace FileTypes { + /** + * A single Animation JSON File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#animation method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#animation. + */ + class AnimationJSONFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param xhrSettings Extra XHR Settings specifically for this file. + * @param dataKey When the JSON file loads only this property will be stored in the Cache. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.JSONFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, dataKey?: string); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + /** + * Called at the end of the load process, after the Loader has finished all files in its queue. + */ + onLoadComplete(): void; + + } + + /** + * A single JSON based Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#atlas method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlas. + * + * https://www.codeandweb.com/texturepacker/tutorials/how-to-create-sprite-sheets-for-phaser3?source=photonstorm + */ + class AsepriteFile extends Phaser.Loader.MultiFile { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param textureURL The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param atlasURL The absolute or relative URL to load the texture atlas json data file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, a well formed JSON object. + * @param textureXhrSettings An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param atlasXhrSettings An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AsepriteFileConfig, textureURL?: string | string[], atlasURL?: object | string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A single JSON based Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#atlas method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlas. + * + * https://www.codeandweb.com/texturepacker/tutorials/how-to-create-sprite-sheets-for-phaser3?source=photonstorm + */ + class AtlasJSONFile extends Phaser.Loader.MultiFile { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param textureURL The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param atlasURL The absolute or relative URL to load the texture atlas json data file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, a well formed JSON object. + * @param textureXhrSettings An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param atlasXhrSettings An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AtlasJSONFileConfig, textureURL?: string | string[], atlasURL?: object | string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A single XML based Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#atlasXML method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlasXML. + */ + class AtlasXMLFile extends Phaser.Loader.MultiFile { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param textureURL The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param atlasURL The absolute or relative URL to load the texture atlas xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param textureXhrSettings An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param atlasXhrSettings An XHR Settings configuration object for the atlas xml file. Used in replacement of the Loaders default XHR Settings. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AtlasXMLFileConfig, textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A single Audio File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#audio method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audio. + */ + class AudioFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param urlConfig The absolute or relative URL to load this file from in a config object. + * @param xhrSettings Extra XHR Settings specifically for this file. + * @param audioContext The AudioContext this file will use to process itself. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AudioFileConfig, urlConfig?: any, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, audioContext?: AudioContext); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + /** + * An Audio Sprite File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#audioSprite method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audioSprite. + */ + class AudioSpriteFile extends Phaser.Loader.MultiFile { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param jsonURL The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. + * @param audioURL The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. + * @param audioConfig The audio configuration options. + * @param audioXhrSettings An XHR Settings configuration object for the audio file. Used in replacement of the Loaders default XHR Settings. + * @param jsonXhrSettings An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AudioSpriteFileConfig, jsonURL: string, audioURL?: Object, audioConfig?: any, audioXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, jsonXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called by each File when it finishes loading. + * @param file The File that has completed processing. + */ + onFileComplete(file: Phaser.Loader.File): void; + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A single Binary File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#binary method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#binary. + */ + class BinaryFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". + * @param xhrSettings Extra XHR Settings specifically for this file. + * @param dataType Optional type to cast the binary file to once loaded. For example, `Uint8Array`. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.BinaryFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, dataType?: any); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + /** + * A single Bitmap Font based File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#bitmapFont method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#bitmapFont. + */ + class BitmapFontFile extends Phaser.Loader.MultiFile { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param textureURL The absolute or relative URL to load the font image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param fontDataURL The absolute or relative URL to load the font xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param textureXhrSettings An XHR Settings configuration object for the font image file. Used in replacement of the Loaders default XHR Settings. + * @param fontDataXhrSettings An XHR Settings configuration object for the font data xml file. Used in replacement of the Loaders default XHR Settings. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.BitmapFontFileConfig, textureURL?: string | string[], fontDataURL?: string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, fontDataXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A single CSS File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#css method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#css. + */ + class CSSFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.CSSFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + /** + * A single GLSL File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#glsl method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#glsl. + */ + class GLSLFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param shaderType The type of shader. Either `fragment` for a fragment shader, or `vertex` for a vertex shader. This is ignored if you load a shader bundle. Default 'fragment'. + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.GLSLFileConfig, url?: string, shaderType?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + /** + * Returns the name of the shader from the header block. + * @param headerSource The header data. + */ + getShaderName(headerSource: string[]): string; + + /** + * Returns the type of the shader from the header block. + * @param headerSource The header data. + */ + getShaderType(headerSource: string[]): string; + + /** + * Returns the shader uniforms from the header block. + * @param headerSource The header data. + */ + getShaderUniforms(headerSource: string[]): any; + + } + + /** + * A single Audio File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#audio method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audio. + */ + class HTML5AudioFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param urlConfig The absolute or relative URL to load this file from. + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AudioFileConfig, urlConfig?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called when the file finishes loading. + */ + onLoad(): void; + + /** + * Called if the file errors while loading. + */ + onError(): void; + + /** + * Called during the file load progress. Is sent a DOM ProgressEvent. + */ + onProgress(): void; + + /** + * Called by the Loader, starts the actual file downloading. + * During the load the methods onLoad, onError and onProgress are called, based on the XHR events. + * You shouldn't normally call this method directly, it's meant to be invoked by the Loader. + */ + load(): void; + + } + + /** + * A single HTML File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#html method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#html. + */ + class HTMLFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.html`, i.e. if `key` was "alien" then the URL will be "alien.html". + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.HTMLFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + /** + * A single HTML File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#htmlTexture method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#htmlTexture. + */ + class HTMLTextureFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param width The width of the texture the HTML will be rendered to. + * @param height The height of the texture the HTML will be rendered to. + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.HTMLTextureFileConfig, url?: string, width?: number, height?: number, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A single Image File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#image method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#image. + */ + class ImageFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param xhrSettings Extra XHR Settings specifically for this file. + * @param frameConfig The frame configuration object. Only provided for, and used by, Sprite Sheets. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.ImageFileConfig, url?: string | string[], xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, frameConfig?: Phaser.Types.Loader.FileTypes.ImageFrameConfig); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A single JSON File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#json method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#json. + */ + class JSONFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, can be a fully formed JSON Object. + * @param xhrSettings Extra XHR Settings specifically for this file. + * @param dataKey When the JSON file loads only this property will be stored in the Cache. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.JSONFileConfig, url?: object | string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, dataKey?: string); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + /** + * A single Multi Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#multiatlas method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#multiatlas. + */ + class MultiAtlasFile extends Phaser.Loader.MultiFile { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key of the file. Must be unique within both the Loader and the Texture Manager. Or a config object. + * @param atlasURL The absolute or relative URL to load the multi atlas json file from. + * @param path Optional path to use when loading the textures defined in the atlas data. + * @param baseURL Optional Base URL to use when loading the textures defined in the atlas data. + * @param atlasXhrSettings Extra XHR Settings specifically for the atlas json file. + * @param textureXhrSettings Extra XHR Settings specifically for the texture files. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.MultiAtlasFileConfig, atlasURL?: string, path?: string, baseURL?: string, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called by each File when it finishes loading. + * @param file The File that has completed processing. + */ + onFileComplete(file: Phaser.Loader.File): void; + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A Multi Script File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#scripts method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#scripts. + */ + class MultiScriptFile extends Phaser.Loader.MultiFile { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url An array of absolute or relative URLs to load the script files from. They are processed in the order given in the array. + * @param xhrSettings An XHR Settings configuration object for the script files. Used in replacement of the Loaders default XHR Settings. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.MultiScriptFileConfig, url?: string[], xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A single Wavefront OBJ File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#obj method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#obj. + */ + class OBJFile extends Phaser.Loader.MultiFile { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param objURL The absolute or relative URL to load the obj file from. If undefined or `null` it will be set to `.obj`, i.e. if `key` was "alien" then the URL will be "alien.obj". + * @param matURL The absolute or relative URL to load the material file from. If undefined or `null` it will be set to `.mat`, i.e. if `key` was "alien" then the URL will be "alien.mat". + * @param flipUV Flip the UV coordinates stored in the model data? + * @param xhrSettings Extra XHR Settings specifically for these files. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.OBJFileConfig, objURL?: string, matURL?: string, flipUV?: boolean, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A single JSON Pack File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#pack method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#pack. + */ + class PackFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param xhrSettings Extra XHR Settings specifically for this file. + * @param dataKey When the JSON file loads only this property will be stored in the Cache. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.PackFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, dataKey?: string); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + /** + * A single Plugin Script File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#plugin method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#plugin. + */ + class PluginFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param start Automatically start the plugin after loading? Default false. + * @param mapping If this plugin is to be injected into the Scene, this is the property key used. + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.PluginFileConfig, url?: string, start?: boolean, mapping?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + /** + * A single SVG File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#svg method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#svg. + */ + class SVGFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". + * @param svgConfig The svg size configuration object. + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.SVGFileConfig, url?: string, svgConfig?: Phaser.Types.Loader.FileTypes.SVGSizeConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * An external Scene JavaScript File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#sceneFile method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#sceneFile. + */ + class SceneFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.SceneFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A single Scene Plugin Script File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#scenePlugin method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#scenePlugin. + */ + class ScenePluginFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param systemKey If this plugin is to be added to Scene.Systems, this is the property key for it. + * @param sceneKey If this plugin is to be added to the Scene, this is the property key for it. + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.ScenePluginFileConfig, url?: string, systemKey?: string, sceneKey?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + /** + * A single Script File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#script method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#script. + */ + class ScriptFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.ScriptFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + /** + * A single Sprite Sheet Image File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#spritesheet method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#spritesheet. + */ + class SpriteSheetFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param frameConfig The frame configuration object. + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.SpriteSheetFileConfig, url?: string | string[], frameConfig?: Phaser.Types.Loader.FileTypes.ImageFrameConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A single Text File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#text method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#text. + */ + class TextFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.TextFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + /** + * A single Tilemap CSV File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapCSV method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapCSV. + */ + class TilemapCSVFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.csv`, i.e. if `key` was "alien" then the URL will be "alien.csv". + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.TilemapCSVFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A single Impact.js Tilemap JSON File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapImpact method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapImpact. + */ + class TilemapImpactFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.TilemapImpactFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A single Tiled Tilemap JSON File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapTiledJSON method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapTiledJSON. + */ + class TilemapJSONFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, a well formed JSON object. + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.TilemapJSONFileConfig, url?: object | string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A single text file based Unity Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#unityAtlas method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#unityAtlas. + */ + class UnityAtlasFile extends Phaser.Loader.MultiFile { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param textureURL The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param atlasURL The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param textureXhrSettings An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param atlasXhrSettings An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.UnityAtlasFileConfig, textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A single Video File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#video method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#video. + */ + class VideoFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param urlConfig The absolute or relative URL to load this file from in a config object. + * @param loadEvent The load event to listen for when _not_ loading as a blob. Either 'loadeddata', 'canplay' or 'canplaythrough'. + * @param asBlob Load the video as a data blob, or via the Video element? + * @param noAudio Does the video have an audio track? If not you can enable auto-playing on it. + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.VideoFileConfig, urlConfig?: any, loadEvent?: string, asBlob?: boolean, noAudio?: boolean, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + /** + * Called by the Loader, starts the actual file downloading. + * During the load the methods onLoad, onError and onProgress are called, based on the XHR events. + * You shouldn't normally call this method directly, it's meant to be invoked by the Loader. + */ + load(): void; + + } + + /** + * A single XML File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#xml method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#xml. + */ + class XMLFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.XMLFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + } + + } + + namespace Math { /** * Calculate the mean average of the given values. * @param values The values to average. @@ -56895,49 +56782,6 @@ declare namespace Phaser { */ function Clamp(value: number, min: number, max: number): number; - /** - * The value of PI * 2. - */ - var PI2: number; - - /** - * The value of PI * 0.5. - */ - var TAU: number; - - /** - * An epsilon value (1.0e-6) - */ - var EPSILON: number; - - /** - * For converting degrees to radians (PI / 180) - */ - var DEG_TO_RAD: number; - - /** - * For converting radians to degrees (180 / PI) - */ - var RAD_TO_DEG: number; - - /** - * An instance of the Random Number Generator. - * This is not set until the Game boots. - */ - var RND: Phaser.Math.RandomDataGenerator; - - /** - * The minimum safe integer this browser supports. - * We use a const for backward compatibility with Internet Explorer. - */ - var MIN_SAFE_INTEGER: number; - - /** - * The maximum safe integer this browser supports. - * We use a const for backward compatibility with Internet Explorer. - */ - var MAX_SAFE_INTEGER: number; - /** * Convert the given angle from degrees, to the equivalent angle in radians. * @param degrees The angle (in degrees) to convert to radians. @@ -56951,313 +56795,6 @@ declare namespace Phaser { */ function Difference(a: number, b: number): number; - namespace Distance { - /** - * Calculate the distance between two sets of coordinates (points). - * @param x1 The x coordinate of the first point. - * @param y1 The y coordinate of the first point. - * @param x2 The x coordinate of the second point. - * @param y2 The y coordinate of the second point. - */ - function Between(x1: number, y1: number, x2: number, y2: number): number; - - /** - * Calculate the distance between two points. - * @param a The first point. - * @param b The second point. - */ - function BetweenPoints(a: Phaser.Types.Math.Vector2Like, b: Phaser.Types.Math.Vector2Like): number; - - /** - * Calculate the squared distance between two points. - * @param a The first point. - * @param b The second point. - */ - function BetweenPointsSquared(a: Phaser.Types.Math.Vector2Like, b: Phaser.Types.Math.Vector2Like): number; - - /** - * Calculate the Chebyshev distance between two sets of coordinates (points). - * - * Chebyshev distance (or chessboard distance) is the maximum of the horizontal and vertical distances. - * It's the effective distance when movement can be horizontal, vertical, or diagonal. - * @param x1 The x coordinate of the first point. - * @param y1 The y coordinate of the first point. - * @param x2 The x coordinate of the second point. - * @param y2 The y coordinate of the second point. - */ - function Chebyshev(x1: number, y1: number, x2: number, y2: number): number; - - /** - * Calculate the distance between two sets of coordinates (points) to the power of `pow`. - * @param x1 The x coordinate of the first point. - * @param y1 The y coordinate of the first point. - * @param x2 The x coordinate of the second point. - * @param y2 The y coordinate of the second point. - * @param pow The exponent. - */ - function Power(x1: number, y1: number, x2: number, y2: number, pow: number): number; - - /** - * Calculate the snake distance between two sets of coordinates (points). - * - * Snake distance (rectilinear distance, Manhattan distance) is the sum of the horizontal and vertical distances. - * It's the effective distance when movement is allowed only horizontally or vertically (but not both). - * @param x1 The x coordinate of the first point. - * @param y1 The y coordinate of the first point. - * @param x2 The x coordinate of the second point. - * @param y2 The y coordinate of the second point. - */ - function Snake(x1: number, y1: number, x2: number, y2: number): number; - - /** - * Calculate the distance between two sets of coordinates (points), squared. - * @param x1 The x coordinate of the first point. - * @param y1 The y coordinate of the first point. - * @param x2 The x coordinate of the second point. - * @param y2 The y coordinate of the second point. - */ - function Squared(x1: number, y1: number, x2: number, y2: number): number; - - } - - namespace Easing { - namespace Back { - /** - * Back ease-in. - * @param v The value to be tweened. - * @param overshoot The overshoot amount. Default 1.70158. - */ - function In(v: number, overshoot?: number): number; - - /** - * Back ease-in/out. - * @param v The value to be tweened. - * @param overshoot The overshoot amount. Default 1.70158. - */ - function InOut(v: number, overshoot?: number): number; - - /** - * Back ease-out. - * @param v The value to be tweened. - * @param overshoot The overshoot amount. Default 1.70158. - */ - function Out(v: number, overshoot?: number): number; - - } - - namespace Bounce { - /** - * Bounce ease-in. - * @param v The value to be tweened. - */ - function In(v: number): number; - - /** - * Bounce ease-in/out. - * @param v The value to be tweened. - */ - function InOut(v: number): number; - - /** - * Bounce ease-out. - * @param v The value to be tweened. - */ - function Out(v: number): number; - - } - - namespace Circular { - /** - * Circular ease-in. - * @param v The value to be tweened. - */ - function In(v: number): number; - - /** - * Circular ease-in/out. - * @param v The value to be tweened. - */ - function InOut(v: number): number; - - /** - * Circular ease-out. - * @param v The value to be tweened. - */ - function Out(v: number): number; - - } - - namespace Cubic { - /** - * Cubic ease-in. - * @param v The value to be tweened. - */ - function In(v: number): number; - - /** - * Cubic ease-in/out. - * @param v The value to be tweened. - */ - function InOut(v: number): number; - - /** - * Cubic ease-out. - * @param v The value to be tweened. - */ - function Out(v: number): number; - - } - - namespace Elastic { - /** - * Elastic ease-in. - * @param v The value to be tweened. - * @param amplitude The amplitude of the elastic ease. Default 0.1. - * @param period Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. Default 0.1. - */ - function In(v: number, amplitude?: number, period?: number): number; - - /** - * Elastic ease-in/out. - * @param v The value to be tweened. - * @param amplitude The amplitude of the elastic ease. Default 0.1. - * @param period Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. Default 0.1. - */ - function InOut(v: number, amplitude?: number, period?: number): number; - - /** - * Elastic ease-out. - * @param v The value to be tweened. - * @param amplitude The amplitude of the elastic ease. Default 0.1. - * @param period Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. Default 0.1. - */ - function Out(v: number, amplitude?: number, period?: number): number; - - } - - namespace Expo { - /** - * Exponential ease-in. - * @param v The value to be tweened. - */ - function In(v: number): number; - - /** - * Exponential ease-in/out. - * @param v The value to be tweened. - */ - function InOut(v: number): number; - - /** - * Exponential ease-out. - * @param v The value to be tweened. - */ - function Out(v: number): number; - - } - - /** - * Linear easing (no variation). - * @param v The value to be tweened. - */ - function Linear(v: number): number; - - namespace Quadratic { - /** - * Quadratic ease-in. - * @param v The value to be tweened. - */ - function In(v: number): number; - - /** - * Quadratic ease-in/out. - * @param v The value to be tweened. - */ - function InOut(v: number): number; - - /** - * Quadratic ease-out. - * @param v The value to be tweened. - */ - function Out(v: number): number; - - } - - namespace Quartic { - /** - * Quartic ease-in. - * @param v The value to be tweened. - */ - function In(v: number): number; - - /** - * Quartic ease-in/out. - * @param v The value to be tweened. - */ - function InOut(v: number): number; - - /** - * Quartic ease-out. - * @param v The value to be tweened. - */ - function Out(v: number): number; - - } - - namespace Quintic { - /** - * Quintic ease-in. - * @param v The value to be tweened. - */ - function In(v: number): number; - - /** - * Quintic ease-in/out. - * @param v The value to be tweened. - */ - function InOut(v: number): number; - - /** - * Quintic ease-out. - * @param v The value to be tweened. - */ - function Out(v: number): number; - - } - - namespace Sine { - /** - * Sinusoidal ease-in. - * @param v The value to be tweened. - */ - function In(v: number): number; - - /** - * Sinusoidal ease-in/out. - * @param v The value to be tweened. - */ - function InOut(v: number): number; - - /** - * Sinusoidal ease-out. - * @param v The value to be tweened. - */ - function Out(v: number): number; - - } - - namespace Stepped { - } - - /** - * Stepped easing. - * @param v The value to be tweened. - * @param steps The number of steps in the ease. Default 1. - */ - function Stepped(v: number, steps?: number): number; - - } - class Euler { /** * @@ -57300,53 +56837,6 @@ declare namespace Phaser { */ function FromPercent(percent: number, min: number, max?: number): number; - namespace Fuzzy { - /** - * Calculate the fuzzy ceiling of the given value. - * @param value The value. - * @param epsilon The epsilon. Default 0.0001. - */ - function Ceil(value: number, epsilon?: number): number; - - /** - * Check whether the given values are fuzzily equal. - * - * Two numbers are fuzzily equal if their difference is less than `epsilon`. - * @param a The first value. - * @param b The second value. - * @param epsilon The epsilon. Default 0.0001. - */ - function Equal(a: number, b: number, epsilon?: number): boolean; - - /** - * Calculate the fuzzy floor of the given value. - * @param value The value. - * @param epsilon The epsilon. Default 0.0001. - */ - function Floor(value: number, epsilon?: number): number; - - /** - * Check whether `a` is fuzzily greater than `b`. - * - * `a` is fuzzily greater than `b` if it is more than `b - epsilon`. - * @param a The first value. - * @param b The second value. - * @param epsilon The epsilon. Default 0.0001. - */ - function GreaterThan(a: number, b: number, epsilon?: number): boolean; - - /** - * Check whether `a` is fuzzily less than `b`. - * - * `a` is fuzzily less than `b` if it is less than `b + epsilon`. - * @param a The first value. - * @param b The second value. - * @param epsilon The epsilon. Default 0.0001. - */ - function LessThan(a: number, b: number, epsilon?: number): boolean; - - } - /** * Calculate a per-ms speed from a distance and time (given in seconds). * @param distance The distance. @@ -57354,67 +56844,6 @@ declare namespace Phaser { */ function GetSpeed(distance: number, time: number): number; - namespace Interpolation { - /** - * A bezier interpolation method. - * @param v The input array of values to interpolate between. - * @param k The percentage of interpolation, between 0 and 1. - */ - function Bezier(v: number[], k: number): number; - - /** - * A Catmull-Rom interpolation method. - * @param v The input array of values to interpolate between. - * @param k The percentage of interpolation, between 0 and 1. - */ - function CatmullRom(v: number[], k: number): number; - - /** - * A cubic bezier interpolation method. - * - * https://medium.com/@adrian_cooney/bezier-interpolation-13b68563313a - * @param t The percentage of interpolation, between 0 and 1. - * @param p0 The start point. - * @param p1 The first control point. - * @param p2 The second control point. - * @param p3 The end point. - */ - function CubicBezier(t: number, p0: number, p1: number, p2: number, p3: number): number; - - /** - * A linear interpolation method. - * @param v The input array of values to interpolate between. - * @param k The percentage of interpolation, between 0 and 1. - */ - function Linear(v: number[], k: number): number; - - /** - * A quadratic bezier interpolation method. - * @param t The percentage of interpolation, between 0 and 1. - * @param p0 The start point. - * @param p1 The control point. - * @param p2 The end point. - */ - function QuadraticBezier(t: number, p0: number, p1: number, p2: number): number; - - /** - * A Smoother Step interpolation method. - * @param t The percentage of interpolation, between 0 and 1. - * @param min The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. - * @param max The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. - */ - function SmootherStep(t: number, min: number, max: number): number; - - /** - * A Smooth Step interpolation method. - * @param t The percentage of interpolation, between 0 and 1. - * @param min The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. - * @param max The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. - */ - function SmoothStep(t: number, min: number, max: number): number; - - } - /** * Check if a given value is an even number. * @param value The number to perform the check with. @@ -57896,29 +57325,6 @@ declare namespace Phaser { */ function Percent(value: number, min: number, max?: number, upperMax?: number): number; - namespace Pow2 { - /** - * Returns the nearest power of 2 to the given `value`. - * @param value The value. - */ - function GetNext(value: number): number; - - /** - * Checks if the given `width` and `height` are a power of two. - * Useful for checking texture dimensions. - * @param width The width. - * @param height The height. - */ - function IsSize(width: number, height: number): boolean; - - /** - * Tests the value and returns `true` if it is a power of two. - * @param value The value to check if it's a power of two. - */ - function IsValue(value: number): boolean; - - } - /** * A quaternion. */ @@ -58124,149 +57530,6 @@ declare namespace Phaser { */ function RadToDeg(radians: number): number; - /** - * A seeded Random Data Generator. - * - * Access via `Phaser.Math.RND` which is an instance of this class pre-defined - * by Phaser. Or, create your own instance to use as you require. - * - * The `Math.RND` generator is seeded by the Game Config property value `seed`. - * If no such config property exists, a random number is used. - * - * If you create your own instance of this class you should provide a seed for it. - * If no seed is given it will use a 'random' one based on Date.now. - */ - class RandomDataGenerator { - /** - * - * @param seeds The seeds to use for the random number generator. - */ - constructor(seeds?: string | string[]); - - /** - * Signs to choose from. - */ - signs: number[]; - - /** - * Initialize the state of the random data generator. - * @param seeds The seeds to initialize the random data generator with. - */ - init(seeds: string | string[]): void; - - /** - * Reset the seed of the random data generator. - * - * _Note_: the seed array is only processed up to the first `undefined` (or `null`) value, should such be present. - * @param seeds The array of seeds: the `toString()` of each value is used. - */ - sow(seeds: string[]): void; - - /** - * Returns a random integer between 0 and 2^32. - */ - integer(): number; - - /** - * Returns a random real number between 0 and 1. - */ - frac(): number; - - /** - * Returns a random real number between 0 and 2^32. - */ - real(): number; - - /** - * Returns a random integer between and including min and max. - * @param min The minimum value in the range. - * @param max The maximum value in the range. - */ - integerInRange(min: number, max: number): number; - - /** - * Returns a random integer between and including min and max. - * This method is an alias for RandomDataGenerator.integerInRange. - * @param min The minimum value in the range. - * @param max The maximum value in the range. - */ - between(min: number, max: number): number; - - /** - * Returns a random real number between min and max. - * @param min The minimum value in the range. - * @param max The maximum value in the range. - */ - realInRange(min: number, max: number): number; - - /** - * Returns a random real number between -1 and 1. - */ - normal(): number; - - /** - * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368 - */ - uuid(): string; - - /** - * Returns a random element from within the given array. - * @param array The array to pick a random element from. - */ - pick(array: T[]): T; - - /** - * Returns a sign to be used with multiplication operator. - */ - sign(): number; - - /** - * Returns a random element from within the given array, favoring the earlier entries. - * @param array The array to pick a random element from. - */ - weightedPick(array: T[]): T; - - /** - * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified. - * @param min The minimum value in the range. - * @param max The maximum value in the range. - */ - timestamp(min: number, max: number): number; - - /** - * Returns a random angle between -180 and 180. - */ - angle(): number; - - /** - * Returns a random rotation in radians, between -3.141 and 3.141 - */ - rotation(): number; - - /** - * Gets or Sets the state of the generator. This allows you to retain the values - * that the generator is using between games, i.e. in a game save file. - * - * To seed this generator with a previously saved state you can pass it as the - * `seed` value in your game config, or call this method directly after Phaser has booted. - * - * Call this method with no parameters to return the current state. - * - * If providing a state it should match the same format that this method - * returns, which is a string with a header `!rnd` followed by the `c`, - * `s0`, `s1` and `s2` values respectively, each comma-delimited. - * @param state Generator state to be set. - */ - state(state?: string): string; - - /** - * Shuffles the given array, using the current seed. - * @param array The array to be shuffled. - */ - shuffle(array?: T[]): T[]; - - } - /** * Compute a random unit vector. * @@ -58383,6 +57646,18 @@ declare namespace Phaser { */ function SinCosTableGenerator(length: number, sinAmp?: number, cosAmp?: number, frequency?: number): Phaser.Types.Math.SinCosTable; + /** + * Calculate a smooth interpolation percentage of `x` between `min` and `max`. + * + * The function receives the number `x` as an argument and returns 0 if `x` is less than or equal to the left edge, + * 1 if `x` is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, + * between 0 and 1 otherwise. + * @param x The input value. + * @param min The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. + * @param max The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. + */ + function SmoothStep(x: number, min: number, max: number): number; + /** * Calculate a smoother interpolation percentage of `x` between `min` and `max`. * @@ -58397,56 +57672,6 @@ declare namespace Phaser { */ function SmootherStep(x: number, min: number, max: number): number; - /** - * Calculate a smooth interpolation percentage of `x` between `min` and `max`. - * - * The function receives the number `x` as an argument and returns 0 if `x` is less than or equal to the left edge, - * 1 if `x` is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, - * between 0 and 1 otherwise. - * @param x The input value. - * @param min The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. - * @param max The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. - */ - function SmoothStep(x: number, min: number, max: number): number; - - namespace Snap { - /** - * Snap a value to nearest grid slice, using ceil. - * - * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `15`. - * As will `14` snap to `15`... but `16` will snap to `20`. - * @param value The value to snap. - * @param gap The interval gap of the grid. - * @param start Optional starting offset for gap. Default 0. - * @param divide If `true` it will divide the snapped value by the gap before returning. Default false. - */ - function Ceil(value: number, gap: number, start?: number, divide?: boolean): number; - - /** - * Snap a value to nearest grid slice, using floor. - * - * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `10`. - * As will `14` snap to `10`... but `16` will snap to `15`. - * @param value The value to snap. - * @param gap The interval gap of the grid. - * @param start Optional starting offset for gap. Default 0. - * @param divide If `true` it will divide the snapped value by the gap before returning. Default false. - */ - function Floor(value: number, gap: number, start?: number, divide?: boolean): number; - - /** - * Snap a value to nearest grid slice, using rounding. - * - * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `10` whereas `14` will snap to `15`. - * @param value The value to snap. - * @param gap The interval gap of the grid. - * @param start Optional starting offset for gap. Default 0. - * @param divide If `true` it will divide the snapped value by the gap before returning. Default false. - */ - function To(value: number, gap: number, start?: number, divide?: boolean): number; - - } - /** * Returns a Vector2 containing the x and y position of the given index in a `width` x `height` sized grid. * @@ -59280,6 +58505,788 @@ declare namespace Phaser { */ function Wrap(value: number, min: number, max: number): number; + namespace Angle { + /** + * Find the angle of a segment from (x1, y1) -> (x2, y2). + * @param x1 The x coordinate of the first point. + * @param y1 The y coordinate of the first point. + * @param x2 The x coordinate of the second point. + * @param y2 The y coordinate of the second point. + */ + function Between(x1: number, y1: number, x2: number, y2: number): number; + + /** + * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). + * + * Calculates the angle of the vector from the first point to the second point. + * @param point1 The first point. + * @param point2 The second point. + */ + function BetweenPoints(point1: Phaser.Types.Math.Vector2Like, point2: Phaser.Types.Math.Vector2Like): number; + + /** + * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). + * + * The difference between this method and {@link Phaser.Math.Angle.BetweenPoints} is that this assumes the y coordinate + * travels down the screen. + * @param point1 The first point. + * @param point2 The second point. + */ + function BetweenPointsY(point1: Phaser.Types.Math.Vector2Like, point2: Phaser.Types.Math.Vector2Like): number; + + /** + * Find the angle of a segment from (x1, y1) -> (x2, y2). + * + * The difference between this method and {@link Phaser.Math.Angle.Between} is that this assumes the y coordinate + * travels down the screen. + * @param x1 The x coordinate of the first point. + * @param y1 The y coordinate of the first point. + * @param x2 The x coordinate of the second point. + * @param y2 The y coordinate of the second point. + */ + function BetweenY(x1: number, y1: number, x2: number, y2: number): number; + + /** + * Takes an angle in Phasers default clockwise format and converts it so that + * 0 is North, 90 is West, 180 is South and 270 is East, + * therefore running counter-clockwise instead of clockwise. + * + * You can pass in the angle from a Game Object using: + * + * ```javascript + * var converted = CounterClockwise(gameobject.rotation); + * ``` + * + * All values for this function are in radians. + * @param angle The angle to convert, in radians. + */ + function CounterClockwise(angle: number): number; + + /** + * Normalize an angle to the [0, 2pi] range. + * @param angle The angle to normalize, in radians. + */ + function Normalize(angle: number): number; + + /** + * Returns a random angle in the range [-pi, pi]. + */ + function Random(): number; + + /** + * Returns a random angle in the range [-180, 180]. + */ + function RandomDegrees(): number; + + /** + * Reverse the given angle. + * @param angle The angle to reverse, in radians. + */ + function Reverse(angle: number): number; + + /** + * Rotates `currentAngle` towards `targetAngle`, taking the shortest rotation distance. The `lerp` argument is the amount to rotate by in this call. + * @param currentAngle The current angle, in radians. + * @param targetAngle The target angle to rotate to, in radians. + * @param lerp The lerp value to add to the current angle. Default 0.05. + */ + function RotateTo(currentAngle: number, targetAngle: number, lerp?: number): number; + + /** + * Gets the shortest angle between `angle1` and `angle2`. + * + * Both angles must be in the range -180 to 180, which is the same clamped + * range that `sprite.angle` uses, so you can pass in two sprite angles to + * this method and get the shortest angle back between the two of them. + * + * The angle returned will be in the same range. If the returned angle is + * greater than 0 then it's a counter-clockwise rotation, if < 0 then it's + * a clockwise rotation. + * @param angle1 The first angle in the range -180 to 180. + * @param angle2 The second angle in the range -180 to 180. + */ + function ShortestBetween(angle1: number, angle2: number): number; + + /** + * Wrap an angle. + * + * Wraps the angle to a value in the range of -PI to PI. + * @param angle The angle to wrap, in radians. + */ + function Wrap(angle: number): number; + + /** + * Wrap an angle in degrees. + * + * Wraps the angle to a value in the range of -180 to 180. + * @param angle The angle to wrap, in degrees. + */ + function WrapDegrees(angle: number): number; + + } + + /** + * The value of PI * 2. + */ + var PI2: number; + + /** + * The value of PI * 0.5. + */ + var TAU: number; + + /** + * An epsilon value (1.0e-6) + */ + var EPSILON: number; + + /** + * For converting degrees to radians (PI / 180) + */ + var DEG_TO_RAD: number; + + /** + * For converting radians to degrees (180 / PI) + */ + var RAD_TO_DEG: number; + + /** + * An instance of the Random Number Generator. + * This is not set until the Game boots. + */ + var RND: Phaser.Math.RandomDataGenerator; + + /** + * The minimum safe integer this browser supports. + * We use a const for backward compatibility with Internet Explorer. + */ + var MIN_SAFE_INTEGER: number; + + /** + * The maximum safe integer this browser supports. + * We use a const for backward compatibility with Internet Explorer. + */ + var MAX_SAFE_INTEGER: number; + + namespace Distance { + /** + * Calculate the distance between two sets of coordinates (points). + * @param x1 The x coordinate of the first point. + * @param y1 The y coordinate of the first point. + * @param x2 The x coordinate of the second point. + * @param y2 The y coordinate of the second point. + */ + function Between(x1: number, y1: number, x2: number, y2: number): number; + + /** + * Calculate the distance between two points. + * @param a The first point. + * @param b The second point. + */ + function BetweenPoints(a: Phaser.Types.Math.Vector2Like, b: Phaser.Types.Math.Vector2Like): number; + + /** + * Calculate the squared distance between two points. + * @param a The first point. + * @param b The second point. + */ + function BetweenPointsSquared(a: Phaser.Types.Math.Vector2Like, b: Phaser.Types.Math.Vector2Like): number; + + /** + * Calculate the Chebyshev distance between two sets of coordinates (points). + * + * Chebyshev distance (or chessboard distance) is the maximum of the horizontal and vertical distances. + * It's the effective distance when movement can be horizontal, vertical, or diagonal. + * @param x1 The x coordinate of the first point. + * @param y1 The y coordinate of the first point. + * @param x2 The x coordinate of the second point. + * @param y2 The y coordinate of the second point. + */ + function Chebyshev(x1: number, y1: number, x2: number, y2: number): number; + + /** + * Calculate the distance between two sets of coordinates (points) to the power of `pow`. + * @param x1 The x coordinate of the first point. + * @param y1 The y coordinate of the first point. + * @param x2 The x coordinate of the second point. + * @param y2 The y coordinate of the second point. + * @param pow The exponent. + */ + function Power(x1: number, y1: number, x2: number, y2: number, pow: number): number; + + /** + * Calculate the snake distance between two sets of coordinates (points). + * + * Snake distance (rectilinear distance, Manhattan distance) is the sum of the horizontal and vertical distances. + * It's the effective distance when movement is allowed only horizontally or vertically (but not both). + * @param x1 The x coordinate of the first point. + * @param y1 The y coordinate of the first point. + * @param x2 The x coordinate of the second point. + * @param y2 The y coordinate of the second point. + */ + function Snake(x1: number, y1: number, x2: number, y2: number): number; + + /** + * Calculate the distance between two sets of coordinates (points), squared. + * @param x1 The x coordinate of the first point. + * @param y1 The y coordinate of the first point. + * @param x2 The x coordinate of the second point. + * @param y2 The y coordinate of the second point. + */ + function Squared(x1: number, y1: number, x2: number, y2: number): number; + + } + + namespace Easing { + namespace Back { + /** + * Back ease-in. + * @param v The value to be tweened. + * @param overshoot The overshoot amount. Default 1.70158. + */ + function In(v: number, overshoot?: number): number; + + /** + * Back ease-in/out. + * @param v The value to be tweened. + * @param overshoot The overshoot amount. Default 1.70158. + */ + function InOut(v: number, overshoot?: number): number; + + /** + * Back ease-out. + * @param v The value to be tweened. + * @param overshoot The overshoot amount. Default 1.70158. + */ + function Out(v: number, overshoot?: number): number; + + } + + namespace Bounce { + /** + * Bounce ease-in. + * @param v The value to be tweened. + */ + function In(v: number): number; + + /** + * Bounce ease-in/out. + * @param v The value to be tweened. + */ + function InOut(v: number): number; + + /** + * Bounce ease-out. + * @param v The value to be tweened. + */ + function Out(v: number): number; + + } + + namespace Circular { + /** + * Circular ease-in. + * @param v The value to be tweened. + */ + function In(v: number): number; + + /** + * Circular ease-in/out. + * @param v The value to be tweened. + */ + function InOut(v: number): number; + + /** + * Circular ease-out. + * @param v The value to be tweened. + */ + function Out(v: number): number; + + } + + namespace Cubic { + /** + * Cubic ease-in. + * @param v The value to be tweened. + */ + function In(v: number): number; + + /** + * Cubic ease-in/out. + * @param v The value to be tweened. + */ + function InOut(v: number): number; + + /** + * Cubic ease-out. + * @param v The value to be tweened. + */ + function Out(v: number): number; + + } + + namespace Elastic { + /** + * Elastic ease-in. + * @param v The value to be tweened. + * @param amplitude The amplitude of the elastic ease. Default 0.1. + * @param period Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. Default 0.1. + */ + function In(v: number, amplitude?: number, period?: number): number; + + /** + * Elastic ease-in/out. + * @param v The value to be tweened. + * @param amplitude The amplitude of the elastic ease. Default 0.1. + * @param period Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. Default 0.1. + */ + function InOut(v: number, amplitude?: number, period?: number): number; + + /** + * Elastic ease-out. + * @param v The value to be tweened. + * @param amplitude The amplitude of the elastic ease. Default 0.1. + * @param period Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. Default 0.1. + */ + function Out(v: number, amplitude?: number, period?: number): number; + + } + + namespace Expo { + /** + * Exponential ease-in. + * @param v The value to be tweened. + */ + function In(v: number): number; + + /** + * Exponential ease-in/out. + * @param v The value to be tweened. + */ + function InOut(v: number): number; + + /** + * Exponential ease-out. + * @param v The value to be tweened. + */ + function Out(v: number): number; + + } + + /** + * Linear easing (no variation). + * @param v The value to be tweened. + */ + function Linear(v: number): number; + + namespace Quadratic { + /** + * Quadratic ease-in. + * @param v The value to be tweened. + */ + function In(v: number): number; + + /** + * Quadratic ease-in/out. + * @param v The value to be tweened. + */ + function InOut(v: number): number; + + /** + * Quadratic ease-out. + * @param v The value to be tweened. + */ + function Out(v: number): number; + + } + + namespace Quartic { + /** + * Quartic ease-in. + * @param v The value to be tweened. + */ + function In(v: number): number; + + /** + * Quartic ease-in/out. + * @param v The value to be tweened. + */ + function InOut(v: number): number; + + /** + * Quartic ease-out. + * @param v The value to be tweened. + */ + function Out(v: number): number; + + } + + namespace Quintic { + /** + * Quintic ease-in. + * @param v The value to be tweened. + */ + function In(v: number): number; + + /** + * Quintic ease-in/out. + * @param v The value to be tweened. + */ + function InOut(v: number): number; + + /** + * Quintic ease-out. + * @param v The value to be tweened. + */ + function Out(v: number): number; + + } + + namespace Sine { + /** + * Sinusoidal ease-in. + * @param v The value to be tweened. + */ + function In(v: number): number; + + /** + * Sinusoidal ease-in/out. + * @param v The value to be tweened. + */ + function InOut(v: number): number; + + /** + * Sinusoidal ease-out. + * @param v The value to be tweened. + */ + function Out(v: number): number; + + } + + /** + * Stepped easing. + * @param v The value to be tweened. + * @param steps The number of steps in the ease. Default 1. + */ + function Stepped(v: number, steps?: number): number; + + namespace Stepped { + } + + } + + namespace Fuzzy { + /** + * Calculate the fuzzy ceiling of the given value. + * @param value The value. + * @param epsilon The epsilon. Default 0.0001. + */ + function Ceil(value: number, epsilon?: number): number; + + /** + * Check whether the given values are fuzzily equal. + * + * Two numbers are fuzzily equal if their difference is less than `epsilon`. + * @param a The first value. + * @param b The second value. + * @param epsilon The epsilon. Default 0.0001. + */ + function Equal(a: number, b: number, epsilon?: number): boolean; + + /** + * Calculate the fuzzy floor of the given value. + * @param value The value. + * @param epsilon The epsilon. Default 0.0001. + */ + function Floor(value: number, epsilon?: number): number; + + /** + * Check whether `a` is fuzzily greater than `b`. + * + * `a` is fuzzily greater than `b` if it is more than `b - epsilon`. + * @param a The first value. + * @param b The second value. + * @param epsilon The epsilon. Default 0.0001. + */ + function GreaterThan(a: number, b: number, epsilon?: number): boolean; + + /** + * Check whether `a` is fuzzily less than `b`. + * + * `a` is fuzzily less than `b` if it is less than `b + epsilon`. + * @param a The first value. + * @param b The second value. + * @param epsilon The epsilon. Default 0.0001. + */ + function LessThan(a: number, b: number, epsilon?: number): boolean; + + } + + namespace Interpolation { + /** + * A bezier interpolation method. + * @param v The input array of values to interpolate between. + * @param k The percentage of interpolation, between 0 and 1. + */ + function Bezier(v: number[], k: number): number; + + /** + * A Catmull-Rom interpolation method. + * @param v The input array of values to interpolate between. + * @param k The percentage of interpolation, between 0 and 1. + */ + function CatmullRom(v: number[], k: number): number; + + /** + * A cubic bezier interpolation method. + * + * https://medium.com/@adrian_cooney/bezier-interpolation-13b68563313a + * @param t The percentage of interpolation, between 0 and 1. + * @param p0 The start point. + * @param p1 The first control point. + * @param p2 The second control point. + * @param p3 The end point. + */ + function CubicBezier(t: number, p0: number, p1: number, p2: number, p3: number): number; + + /** + * A linear interpolation method. + * @param v The input array of values to interpolate between. + * @param k The percentage of interpolation, between 0 and 1. + */ + function Linear(v: number[], k: number): number; + + /** + * A quadratic bezier interpolation method. + * @param t The percentage of interpolation, between 0 and 1. + * @param p0 The start point. + * @param p1 The control point. + * @param p2 The end point. + */ + function QuadraticBezier(t: number, p0: number, p1: number, p2: number): number; + + /** + * A Smooth Step interpolation method. + * @param t The percentage of interpolation, between 0 and 1. + * @param min The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. + * @param max The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. + */ + function SmoothStep(t: number, min: number, max: number): number; + + /** + * A Smoother Step interpolation method. + * @param t The percentage of interpolation, between 0 and 1. + * @param min The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. + * @param max The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. + */ + function SmootherStep(t: number, min: number, max: number): number; + + } + + namespace Pow2 { + /** + * Returns the nearest power of 2 to the given `value`. + * @param value The value. + */ + function GetNext(value: number): number; + + /** + * Checks if the given `width` and `height` are a power of two. + * Useful for checking texture dimensions. + * @param width The width. + * @param height The height. + */ + function IsSize(width: number, height: number): boolean; + + /** + * Tests the value and returns `true` if it is a power of two. + * @param value The value to check if it's a power of two. + */ + function IsValue(value: number): boolean; + + } + + /** + * A seeded Random Data Generator. + * + * Access via `Phaser.Math.RND` which is an instance of this class pre-defined + * by Phaser. Or, create your own instance to use as you require. + * + * The `Math.RND` generator is seeded by the Game Config property value `seed`. + * If no such config property exists, a random number is used. + * + * If you create your own instance of this class you should provide a seed for it. + * If no seed is given it will use a 'random' one based on Date.now. + */ + class RandomDataGenerator { + /** + * + * @param seeds The seeds to use for the random number generator. + */ + constructor(seeds?: string | string[]); + + /** + * Signs to choose from. + */ + signs: number[]; + + /** + * Initialize the state of the random data generator. + * @param seeds The seeds to initialize the random data generator with. + */ + init(seeds: string | string[]): void; + + /** + * Reset the seed of the random data generator. + * + * _Note_: the seed array is only processed up to the first `undefined` (or `null`) value, should such be present. + * @param seeds The array of seeds: the `toString()` of each value is used. + */ + sow(seeds: string[]): void; + + /** + * Returns a random integer between 0 and 2^32. + */ + integer(): number; + + /** + * Returns a random real number between 0 and 1. + */ + frac(): number; + + /** + * Returns a random real number between 0 and 2^32. + */ + real(): number; + + /** + * Returns a random integer between and including min and max. + * @param min The minimum value in the range. + * @param max The maximum value in the range. + */ + integerInRange(min: number, max: number): number; + + /** + * Returns a random integer between and including min and max. + * This method is an alias for RandomDataGenerator.integerInRange. + * @param min The minimum value in the range. + * @param max The maximum value in the range. + */ + between(min: number, max: number): number; + + /** + * Returns a random real number between min and max. + * @param min The minimum value in the range. + * @param max The maximum value in the range. + */ + realInRange(min: number, max: number): number; + + /** + * Returns a random real number between -1 and 1. + */ + normal(): number; + + /** + * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368 + */ + uuid(): string; + + /** + * Returns a random element from within the given array. + * @param array The array to pick a random element from. + */ + pick(array: T[]): T; + + /** + * Returns a sign to be used with multiplication operator. + */ + sign(): number; + + /** + * Returns a random element from within the given array, favoring the earlier entries. + * @param array The array to pick a random element from. + */ + weightedPick(array: T[]): T; + + /** + * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified. + * @param min The minimum value in the range. + * @param max The maximum value in the range. + */ + timestamp(min: number, max: number): number; + + /** + * Returns a random angle between -180 and 180. + */ + angle(): number; + + /** + * Returns a random rotation in radians, between -3.141 and 3.141 + */ + rotation(): number; + + /** + * Gets or Sets the state of the generator. This allows you to retain the values + * that the generator is using between games, i.e. in a game save file. + * + * To seed this generator with a previously saved state you can pass it as the + * `seed` value in your game config, or call this method directly after Phaser has booted. + * + * Call this method with no parameters to return the current state. + * + * If providing a state it should match the same format that this method + * returns, which is a string with a header `!rnd` followed by the `c`, + * `s0`, `s1` and `s2` values respectively, each comma-delimited. + * @param state Generator state to be set. + */ + state(state?: string): string; + + /** + * Shuffles the given array, using the current seed. + * @param array The array to be shuffled. + */ + shuffle(array?: T[]): T[]; + + } + + namespace Snap { + /** + * Snap a value to nearest grid slice, using ceil. + * + * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `15`. + * As will `14` snap to `15`... but `16` will snap to `20`. + * @param value The value to snap. + * @param gap The interval gap of the grid. + * @param start Optional starting offset for gap. Default 0. + * @param divide If `true` it will divide the snapped value by the gap before returning. Default false. + */ + function Ceil(value: number, gap: number, start?: number, divide?: boolean): number; + + /** + * Snap a value to nearest grid slice, using floor. + * + * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `10`. + * As will `14` snap to `10`... but `16` will snap to `15`. + * @param value The value to snap. + * @param gap The interval gap of the grid. + * @param start Optional starting offset for gap. Default 0. + * @param divide If `true` it will divide the snapped value by the gap before returning. Default false. + */ + function Floor(value: number, gap: number, start?: number, divide?: boolean): number; + + /** + * Snap a value to nearest grid slice, using rounding. + * + * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `10` whereas `14` will snap to `15`. + * @param value The value to snap. + * @param gap The interval gap of the grid. + * @param start Optional starting offset for gap. Default 0. + * @param divide If `true` it will divide the snapped value by the gap before returning. Default false. + */ + function To(value: number, gap: number, start?: number, divide?: boolean): number; + + } + } /** @@ -60039,6 +60046,10 @@ declare namespace Phaser { * A WebGL Pipeline configuration object. Can also be part of the `RenderConfig`. */ pipeline?: Phaser.Types.Core.PipelineConfig; + /** + * The background color of the game canvas. The default is black. + */ + backgroundColor?: string | number; /** * When set to `true`, WebGL uses linear interpolation to draw scaled or rotated textures, giving a smooth appearance. When set to `false`, WebGL uses nearest-neighbor interpolation, giving a crisper appearance. `false` also disables antialiasing of the game canvas itself, if the browser supports it, when the game canvas is scaled. */ @@ -62745,8 +62756,6 @@ declare namespace Phaser { shift: Phaser.Input.Keyboard.Key; }; - type KeyboardKeydownCallback = (event: KeyboardEvent)=>void; - type KeyComboConfig = { /** * If they press the wrong key do we reset the combo? @@ -62766,6 +62775,8 @@ declare namespace Phaser { deleteOnMatch?: boolean; }; + type KeyboardKeydownCallback = (event: KeyboardEvent)=>void; + } /** @@ -62812,7 +62823,7 @@ declare namespace Phaser { */ cursor?: string; /** - * If `true` the a pixel perfect function will be set for the hit area callback. Only works with texture based Game Objects. + * If `true` the a pixel perfect function will be set for the hit area callback. Only works with image texture based Game Objects, not Render Textures. */ pixelPerfect?: boolean; /** @@ -63455,6 +63466,44 @@ declare namespace Phaser { xhrSettings?: Phaser.Types.Loader.XHRSettingsObject; }; + type SVGFileConfig = { + /** + * The key of the file. Must be unique within both the Loader and the Texture Manager. + */ + key: string; + /** + * The absolute or relative URL to load the file from. + */ + url?: string; + /** + * The default file extension to use if no url is provided. + */ + extension?: string; + /** + * Extra XHR Settings specifically for this file. + */ + xhrSettings?: Phaser.Types.Loader.XHRSettingsObject; + /** + * The svg size configuration object. + */ + svgConfig?: Phaser.Types.Loader.FileTypes.SVGSizeConfig; + }; + + type SVGSizeConfig = { + /** + * An optional width. The SVG will be resized to this size before being rendered to a texture. + */ + width?: number; + /** + * An optional height. The SVG will be resized to this size before being rendered to a texture. + */ + height?: number; + /** + * An optional scale. If given it overrides the width / height properties. The SVG is scaled by the scale factor before being rendered to a texture. + */ + scale?: number; + }; + type SceneFileConfig = { /** * The key of the file. Must be unique within both the Loader and the Text Cache. @@ -63547,44 +63596,6 @@ declare namespace Phaser { xhrSettings?: Phaser.Types.Loader.XHRSettingsObject; }; - type SVGFileConfig = { - /** - * The key of the file. Must be unique within both the Loader and the Texture Manager. - */ - key: string; - /** - * The absolute or relative URL to load the file from. - */ - url?: string; - /** - * The default file extension to use if no url is provided. - */ - extension?: string; - /** - * Extra XHR Settings specifically for this file. - */ - xhrSettings?: Phaser.Types.Loader.XHRSettingsObject; - /** - * The svg size configuration object. - */ - svgConfig?: Phaser.Types.Loader.FileTypes.SVGSizeConfig; - }; - - type SVGSizeConfig = { - /** - * An optional width. The SVG will be resized to this size before being rendered to a texture. - */ - width?: number; - /** - * An optional height. The SVG will be resized to this size before being rendered to a texture. - */ - height?: number; - /** - * An optional scale. If given it overrides the width / height properties. The SVG is scaled by the scale factor before being rendered to a texture. - */ - scale?: number; - }; - type TextFileConfig = { /** * The key of the file. Must be unique within both the Loader and the Text Cache. @@ -65523,7 +65534,7 @@ declare namespace Phaser { /** * The scene's update callback. See {@link Phaser.Scene#update}. */ - update?: Function; + update?: Phaser.Types.Scenes.SceneUpdateCallback; /** * Any additional properties, which will be copied to the Scene after it's created (except `data` or `sys`). */ @@ -65539,20 +65550,20 @@ declare namespace Phaser { * This method is called by the Scene Manager when the scene starts, after `init()` and `preload()`. * If the LoaderPlugin started after `preload()`, then this method is called only after loading is complete. */ - type SceneCreateCallback = (data: object)=>void; + type SceneCreateCallback = (this: Phaser.Scene, data: object)=>void; /** * Can be defined on your own Scenes. * This method is called by the Scene Manager when the scene starts, before `preload()` and `create()`. */ - type SceneInitCallback = (data: object)=>void; + type SceneInitCallback = (this: Phaser.Scene, data: object)=>void; /** * Can be defined on your own Scenes. Use it to load assets. * This method is called by the Scene Manager, after `init()` and before `create()`, only if the Scene has a LoaderPlugin. * After this method completes, if the LoaderPlugin's queue isn't empty, the LoaderPlugin will start automatically. */ - type ScenePreloadCallback = ()=>void; + type ScenePreloadCallback = (this: Phaser.Scene)=>void; type SceneTransitionConfig = { /** @@ -65597,6 +65608,8 @@ declare namespace Phaser { data?: any; }; + type SceneUpdateCallback = (this: Phaser.Scene)=>void; + type SettingsConfig = { /** * The unique key of this Scene. Must be unique within the entire Game instance. @@ -71099,561 +71112,6 @@ declare namespace Phaser { } - namespace Components { - /** - * Provides methods used for setting the acceleration properties of an Arcade Physics Body. - */ - interface Acceleration { - /** - * Sets the body's horizontal and vertical acceleration. If the vertical acceleration value is not provided, the vertical acceleration is set to the same value as the horizontal acceleration. - * @param x The horizontal acceleration - * @param y The vertical acceleration Default x. - */ - setAcceleration(x: number, y?: number): this; - /** - * Sets the body's horizontal acceleration. - * @param value The horizontal acceleration - */ - setAccelerationX(value: number): this; - /** - * Sets the body's vertical acceleration. - * @param value The vertical acceleration - */ - setAccelerationY(value: number): this; - } - - /** - * Provides methods used for setting the angular acceleration properties of an Arcade Physics Body. - */ - interface Angular { - /** - * Sets the angular velocity of the body. - * - * In Arcade Physics, bodies cannot rotate. They are always axis-aligned. - * However, they can have angular motion, which is passed on to the Game Object bound to the body, - * causing them to visually rotate, even though the body remains axis-aligned. - * @param value The amount of angular velocity. - */ - setAngularVelocity(value: number): this; - /** - * Sets the angular acceleration of the body. - * - * In Arcade Physics, bodies cannot rotate. They are always axis-aligned. - * However, they can have angular motion, which is passed on to the Game Object bound to the body, - * causing them to visually rotate, even though the body remains axis-aligned. - * @param value The amount of angular acceleration. - */ - setAngularAcceleration(value: number): this; - /** - * Sets the angular drag of the body. Drag is applied to the current velocity, providing a form of deceleration. - * @param value The amount of drag. - */ - setAngularDrag(value: number): this; - } - - /** - * Provides methods used for setting the bounce properties of an Arcade Physics Body. - */ - interface Bounce { - /** - * Sets the bounce values of this body. - * - * Bounce is the amount of restitution, or elasticity, the body has when it collides with another object. - * A value of 1 means that it will retain its full velocity after the rebound. A value of 0 means it will not rebound at all. - * @param x The amount of horizontal bounce to apply on collision. A float, typically between 0 and 1. - * @param y The amount of vertical bounce to apply on collision. A float, typically between 0 and 1. Default x. - */ - setBounce(x: number, y?: number): this; - /** - * Sets the horizontal bounce value for this body. - * @param value The amount of horizontal bounce to apply on collision. A float, typically between 0 and 1. - */ - setBounceX(value: number): this; - /** - * Sets the vertical bounce value for this body. - * @param value The amount of vertical bounce to apply on collision. A float, typically between 0 and 1. - */ - setBounceY(value: number): this; - /** - * Sets whether this Body collides with the world boundary. - * - * Optionally also sets the World Bounce values. If the `Body.worldBounce` is null, it's set to a new Phaser.Math.Vector2 first. - * @param value `true` if this body should collide with the world bounds, otherwise `false`. Default true. - * @param bounceX If given this will be replace the `worldBounce.x` value. - * @param bounceY If given this will be replace the `worldBounce.y` value. - */ - setCollideWorldBounds(value?: boolean, bounceX?: number, bounceY?: number): this; - } - - /** - * Provides methods used for setting the debug properties of an Arcade Physics Body. - */ - interface Debug { - /** - * Sets the debug values of this body. - * - * Bodies will only draw their debug if debug has been enabled for Arcade Physics as a whole. - * Note that there is a performance cost in drawing debug displays. It should never be used in production. - * @param showBody Set to `true` to have this body render its outline to the debug display. - * @param showVelocity Set to `true` to have this body render a velocity marker to the debug display. - * @param bodyColor The color of the body outline when rendered to the debug display. - */ - setDebug(showBody: boolean, showVelocity: boolean, bodyColor: number): this; - /** - * Sets the color of the body outline when it renders to the debug display. - * @param value The color of the body outline when rendered to the debug display. - */ - setDebugBodyColor(value: number): this; - /** - * Set to `true` to have this body render its outline to the debug display. - */ - debugShowBody: boolean; - /** - * Set to `true` to have this body render a velocity marker to the debug display. - */ - debugShowVelocity: boolean; - /** - * The color of the body outline when it renders to the debug display. - */ - debugBodyColor: number; - } - - /** - * Provides methods used for setting the drag properties of an Arcade Physics Body. - */ - interface Drag { - /** - * Sets the body's horizontal and vertical drag. If the vertical drag value is not provided, the vertical drag is set to the same value as the horizontal drag. - * - * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. - * It is the absolute loss of velocity due to movement, in pixels per second squared. - * The x and y components are applied separately. - * - * When `useDamping` is true, this is 1 minus the damping factor. - * A value of 1 means the Body loses no velocity. - * A value of 0.95 means the Body loses 5% of its velocity per step. - * A value of 0.5 means the Body loses 50% of its velocity per step. - * - * Drag is applied only when `acceleration` is zero. - * @param x The amount of horizontal drag to apply. - * @param y The amount of vertical drag to apply. Default x. - */ - setDrag(x: number, y?: number): this; - /** - * Sets the body's horizontal drag. - * - * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. - * It is the absolute loss of velocity due to movement, in pixels per second squared. - * The x and y components are applied separately. - * - * When `useDamping` is true, this is 1 minus the damping factor. - * A value of 1 means the Body loses no velocity. - * A value of 0.95 means the Body loses 5% of its velocity per step. - * A value of 0.5 means the Body loses 50% of its velocity per step. - * - * Drag is applied only when `acceleration` is zero. - * @param value The amount of horizontal drag to apply. - */ - setDragX(value: number): this; - /** - * Sets the body's vertical drag. - * - * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. - * It is the absolute loss of velocity due to movement, in pixels per second squared. - * The x and y components are applied separately. - * - * When `useDamping` is true, this is 1 minus the damping factor. - * A value of 1 means the Body loses no velocity. - * A value of 0.95 means the Body loses 5% of its velocity per step. - * A value of 0.5 means the Body loses 50% of its velocity per step. - * - * Drag is applied only when `acceleration` is zero. - * @param value The amount of vertical drag to apply. - */ - setDragY(value: number): this; - /** - * If this Body is using `drag` for deceleration this function controls how the drag is applied. - * If set to `true` drag will use a damping effect rather than a linear approach. If you are - * creating a game where the Body moves freely at any angle (i.e. like the way the ship moves in - * the game Asteroids) then you will get a far smoother and more visually correct deceleration - * by using damping, avoiding the axis-drift that is prone with linear deceleration. - * - * If you enable this property then you should use far smaller `drag` values than with linear, as - * they are used as a multiplier on the velocity. Values such as 0.95 will give a nice slow - * deceleration, where-as smaller values, such as 0.5 will stop an object almost immediately. - * @param value `true` to use damping for deceleration, or `false` to use linear deceleration. - */ - setDamping(value: boolean): this; - } - - /** - * Provides methods used for setting the enable properties of an Arcade Physics Body. - */ - interface Enable { - /** - * Enables this Game Object's Body. - * @param reset Also reset the Body and place it at (x, y). - * @param x The horizontal position to place the Game Object and Body. - * @param y The horizontal position to place the Game Object and Body. - * @param enableGameObject Also activate this Game Object. - * @param showGameObject Also show this Game Object. - */ - enableBody(reset: boolean, x: number, y: number, enableGameObject: boolean, showGameObject: boolean): this; - /** - * Stops and disables this Game Object's Body. - * @param disableGameObject Also deactivate this Game Object. Default false. - * @param hideGameObject Also hide this Game Object. Default false. - */ - disableBody(disableGameObject?: boolean, hideGameObject?: boolean): this; - /** - * Syncs the Body's position and size with its parent Game Object. - * You don't need to call this for Dynamic Bodies, as it happens automatically. - * But for Static bodies it's a useful way of modifying the position of a Static Body - * in the Physics World, based on its Game Object. - */ - refreshBody(): this; - } - - /** - * Methods for setting the friction of an Arcade Physics Body. - * - * In Arcade Physics, friction is a special case of motion transfer from an "immovable" body to a riding body. - */ - interface Friction { - /** - * Sets the friction of this game object's physics body. - * In Arcade Physics, friction is a special case of motion transfer from an "immovable" body to a riding body. - * @param x The amount of horizontal friction to apply, [0, 1]. - * @param y The amount of vertical friction to apply, [0, 1]. Default x. - */ - setFriction(x: number, y?: number): this; - /** - * Sets the horizontal friction of this game object's physics body. - * This can move a riding body horizontally when it collides with this one on the vertical axis. - * @param x The amount of friction to apply, [0, 1]. - */ - setFrictionX(x: number): this; - /** - * Sets the vertical friction of this game object's physics body. - * This can move a riding body vertically when it collides with this one on the horizontal axis. - * @param y The amount of friction to apply, [0, 1]. - */ - setFrictionY(y: number): this; - } - - /** - * Provides methods for setting the gravity properties of an Arcade Physics Game Object. - * Should be applied as a mixin and not used directly. - */ - interface Gravity { - /** - * Set the X and Y values of the gravitational pull to act upon this Arcade Physics Game Object. Values can be positive or negative. Larger values result in a stronger effect. - * - * If only one value is provided, this value will be used for both the X and Y axis. - * @param x The gravitational force to be applied to the X-axis. - * @param y The gravitational force to be applied to the Y-axis. If this is not specified, the X value will be used. Default x. - */ - setGravity(x: number, y?: number): this; - /** - * Set the gravitational force to be applied to the X axis. Value can be positive or negative. Larger values result in a stronger effect. - * @param x The gravitational force to be applied to the X-axis. - */ - setGravityX(x: number): this; - /** - * Set the gravitational force to be applied to the Y axis. Value can be positive or negative. Larger values result in a stronger effect. - * @param y The gravitational force to be applied to the Y-axis. - */ - setGravityY(y: number): this; - } - - /** - * Provides methods used for setting the immovable properties of an Arcade Physics Body. - */ - interface Immovable { - /** - * Sets if this Body can be separated during collisions with other bodies. - * - * When a body is immovable it means it won't move at all, not even to separate it from collision - * overlap. If you just wish to prevent a body from being knocked around by other bodies, see - * the `setPushable` method instead. - * @param value Sets if this body will be separated during collisions with other bodies. Default true. - */ - setImmovable(value?: boolean): this; - } - - /** - * Provides methods used for setting the mass properties of an Arcade Physics Body. - */ - interface Mass { - /** - * Sets the mass of the physics body - * @param value New value for the mass of the body. - */ - setMass(value: number): this; - } - - /** - * This method will search the given circular area and return an array of all physics bodies that - * overlap with it. It can return either Dynamic, Static bodies or a mixture of both. - * - * A body only has to intersect with the search area to be considered, it doesn't have to be fully - * contained within it. - * - * If Arcade Physics is set to use the RTree (which it is by default) then the search is rather fast, - * otherwise the search is O(N) for Dynamic Bodies. - */ - interface OverlapCirc { - } - - /** - * This method will search the given rectangular area and return an array of all physics bodies that - * overlap with it. It can return either Dynamic, Static bodies or a mixture of both. - * - * A body only has to intersect with the search area to be considered, it doesn't have to be fully - * contained within it. - * - * If Arcade Physics is set to use the RTree (which it is by default) then the search for is extremely fast, - * otherwise the search is O(N) for Dynamic Bodies. - */ - interface OverlapRect { - } - - /** - * Provides methods used for setting the pushable property of an Arcade Physics Body. - */ - interface Pushable { - /** - * Sets if this Body can be pushed by another Body. - * - * A body that cannot be pushed will reflect back all of the velocity it is given to the - * colliding body. If that body is also not pushable, then the separation will be split - * between them evenly. - * - * If you want your body to never move or seperate at all, see the `setImmovable` method. - * @param value Sets if this body can be pushed by collisions with another Body. Default true. - */ - setPushable(value?: boolean): this; - } - - /** - * Provides methods for setting the size of an Arcade Physics Game Object. - * Should be applied as a mixin and not used directly. - */ - interface Size { - /** - * Sets the body offset. This allows you to adjust the difference between the center of the body - * and the x and y coordinates of the parent Game Object. - * @param x The amount to offset the body from the parent Game Object along the x-axis. - * @param y The amount to offset the body from the parent Game Object along the y-axis. Defaults to the value given for the x-axis. Default x. - */ - setOffset(x: number, y?: number): this; - /** - * **DEPRECATED**: Please use `setBodySize` instead. - * - * Sets the size of this physics body. Setting the size does not adjust the dimensions of the parent Game Object. - * @param width The new width of the physics body, in pixels. - * @param height The new height of the physics body, in pixels. - * @param center Should the body be re-positioned so its center aligns with the parent Game Object? Default true. - */ - setSize(width: number, height: number, center?: boolean): this; - /** - * Sets the size of this physics body. Setting the size does not adjust the dimensions of the parent Game Object. - * @param width The new width of the physics body, in pixels. - * @param height The new height of the physics body, in pixels. - * @param center Should the body be re-positioned so its center aligns with the parent Game Object? Default true. - */ - setBodySize(width: number, height: number, center?: boolean): this; - /** - * Sets this physics body to use a circle for collision instead of a rectangle. - * @param radius The radius of the physics body, in pixels. - * @param offsetX The amount to offset the body from the parent Game Object along the x-axis. - * @param offsetY The amount to offset the body from the parent Game Object along the y-axis. - */ - setCircle(radius: number, offsetX?: number, offsetY?: number): this; - } - - /** - * Provides methods for modifying the velocity of an Arcade Physics body. - * - * Should be applied as a mixin and not used directly. - */ - interface Velocity { - /** - * Sets the velocity of the Body. - * @param x The horizontal velocity of the body. Positive values move the body to the right, while negative values move it to the left. - * @param y The vertical velocity of the body. Positive values move the body down, while negative values move it up. Default x. - */ - setVelocity(x: number, y?: number): this; - /** - * Sets the horizontal component of the body's velocity. - * - * Positive values move the body to the right, while negative values move it to the left. - * @param x The new horizontal velocity. - */ - setVelocityX(x: number): this; - /** - * Sets the vertical component of the body's velocity. - * - * Positive values move the body down, while negative values move it up. - * @param y The new vertical velocity of the body. - */ - setVelocityY(y: number): this; - /** - * Sets the maximum velocity of the body. - * @param x The new maximum horizontal velocity. - * @param y The new maximum vertical velocity. Default x. - */ - setMaxVelocity(x: number, y?: number): this; - } - - } - - /** - * Dynamic Body. - */ - var DYNAMIC_BODY: number; - - /** - * Static Body. - */ - var STATIC_BODY: number; - - /** - * Arcade Physics Group containing Dynamic Bodies. - */ - var GROUP: number; - - /** - * A Tilemap Layer. - */ - var TILEMAPLAYER: number; - - /** - * Facing no direction (initial value). - */ - var FACING_NONE: number; - - /** - * Facing up. - */ - var FACING_UP: number; - - /** - * Facing down. - */ - var FACING_DOWN: number; - - /** - * Facing left. - */ - var FACING_LEFT: number; - - /** - * Facing right. - */ - var FACING_RIGHT: number; - - namespace Events { - /** - * The Arcade Physics World Collide Event. - * - * This event is dispatched by an Arcade Physics World instance if two bodies collide _and_ at least - * one of them has their [onCollide]{@link Phaser.Physics.Arcade.Body#onCollide} property set to `true`. - * - * It provides an alternative means to handling collide events rather than using the callback approach. - * - * Listen to it from a Scene using: `this.physics.world.on('collide', listener)`. - * - * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. - */ - const COLLIDE: any; - - /** - * The Arcade Physics World Overlap Event. - * - * This event is dispatched by an Arcade Physics World instance if two bodies overlap _and_ at least - * one of them has their [onOverlap]{@link Phaser.Physics.Arcade.Body#onOverlap} property set to `true`. - * - * It provides an alternative means to handling overlap events rather than using the callback approach. - * - * Listen to it from a Scene using: `this.physics.world.on('overlap', listener)`. - * - * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. - */ - const OVERLAP: any; - - /** - * The Arcade Physics World Pause Event. - * - * This event is dispatched by an Arcade Physics World instance when it is paused. - * - * Listen to it from a Scene using: `this.physics.world.on('pause', listener)`. - */ - const PAUSE: any; - - /** - * The Arcade Physics World Resume Event. - * - * This event is dispatched by an Arcade Physics World instance when it resumes from a paused state. - * - * Listen to it from a Scene using: `this.physics.world.on('resume', listener)`. - */ - const RESUME: any; - - /** - * The Arcade Physics Tile Collide Event. - * - * This event is dispatched by an Arcade Physics World instance if a body collides with a Tile _and_ - * has its [onCollide]{@link Phaser.Physics.Arcade.Body#onCollide} property set to `true`. - * - * It provides an alternative means to handling collide events rather than using the callback approach. - * - * Listen to it from a Scene using: `this.physics.world.on('tilecollide', listener)`. - * - * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. - */ - const TILE_COLLIDE: any; - - /** - * The Arcade Physics Tile Overlap Event. - * - * This event is dispatched by an Arcade Physics World instance if a body overlaps with a Tile _and_ - * has its [onOverlap]{@link Phaser.Physics.Arcade.Body#onOverlap} property set to `true`. - * - * It provides an alternative means to handling overlap events rather than using the callback approach. - * - * Listen to it from a Scene using: `this.physics.world.on('tileoverlap', listener)`. - * - * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. - */ - const TILE_OVERLAP: any; - - /** - * The Arcade Physics World Bounds Event. - * - * This event is dispatched by an Arcade Physics World instance if a body makes contact with the world bounds _and_ - * it has its [onWorldBounds]{@link Phaser.Physics.Arcade.Body#onWorldBounds} property set to `true`. - * - * It provides an alternative means to handling collide events rather than using the callback approach. - * - * Listen to it from a Scene using: `this.physics.world.on('worldbounds', listener)`. - */ - const WORLD_BOUNDS: any; - - /** - * The Arcade Physics World Step Event. - * - * This event is dispatched by an Arcade Physics World instance whenever a physics step is run. - * It is emitted _after_ the bodies and colliders have been updated. - * - * In high framerate settings this can be multiple times per game frame. - * - * Listen to it from a Scene using: `this.physics.world.on('worldstep', listener)`. - */ - const WORLD_STEP: any; - - } - /** * The Arcade Physics Factory allows you to easily create Arcade Physics enabled Game Objects. * Objects that are created by this Factory are automatically added to the physics world. @@ -72337,73 +71795,6 @@ declare namespace Phaser { } - namespace Tilemap { - /** - * A function to process the collision callbacks between a single tile and an Arcade Physics enabled Game Object. - * @param tile The Tile to process. - * @param sprite The Game Object to process with the Tile. - */ - function ProcessTileCallbacks(tile: Phaser.Tilemaps.Tile, sprite: Phaser.GameObjects.Sprite): boolean; - - /** - * Internal function to process the separation of a physics body from a tile. - * @param body The Body object to separate. - * @param x The x separation amount. - */ - function ProcessTileSeparationX(body: Phaser.Physics.Arcade.Body, x: number): void; - - /** - * Internal function to process the separation of a physics body from a tile. - * @param body The Body object to separate. - * @param y The y separation amount. - */ - function ProcessTileSeparationY(body: Phaser.Physics.Arcade.Body, y: number): void; - - /** - * The core separation function to separate a physics body and a tile. - * @param i The index of the tile within the map data. - * @param body The Body object to separate. - * @param tile The tile to collide against. - * @param tileWorldRect A rectangle-like object defining the dimensions of the tile. - * @param tilemapLayer The tilemapLayer to collide against. - * @param tileBias The tile bias value. Populated by the `World.TILE_BIAS` constant. - * @param isLayer Is this check coming from a TilemapLayer or an array of tiles? - */ - function SeparateTile(i: number, body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileWorldRect: Phaser.Geom.Rectangle, tilemapLayer: Phaser.Tilemaps.TilemapLayer, tileBias: number, isLayer: boolean): boolean; - - /** - * Check the body against the given tile on the X axis. - * Used internally by the SeparateTile function. - * @param body The Body object to separate. - * @param tile The tile to check. - * @param tileLeft The left position of the tile within the tile world. - * @param tileRight The right position of the tile within the tile world. - * @param tileBias The tile bias value. Populated by the `World.TILE_BIAS` constant. - * @param isLayer Is this check coming from a TilemapLayer or an array of tiles? - */ - function TileCheckX(body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileLeft: number, tileRight: number, tileBias: number, isLayer: boolean): number; - - /** - * Check the body against the given tile on the Y axis. - * Used internally by the SeparateTile function. - * @param body The Body object to separate. - * @param tile The tile to check. - * @param tileTop The top position of the tile within the tile world. - * @param tileBottom The bottom position of the tile within the tile world. - * @param tileBias The tile bias value. Populated by the `World.TILE_BIAS` constant. - * @param isLayer Is this check coming from a TilemapLayer or an array of tiles? - */ - function TileCheckY(body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileTop: number, tileBottom: number, tileBias: number, isLayer: boolean): number; - - /** - * Checks for intersection between the given tile rectangle-like object and an Arcade Physics body. - * @param tileWorldRect A rectangle object that defines the tile placement in the world. - * @param body The body to check for intersection against. - */ - function TileIntersectsBody(tileWorldRect: Object, body: Phaser.Physics.Arcade.Body): boolean; - - } - /** * The Arcade Physics World. * @@ -72988,6 +72379,628 @@ declare namespace Phaser { } + namespace Components { + /** + * Provides methods used for setting the acceleration properties of an Arcade Physics Body. + */ + interface Acceleration { + /** + * Sets the body's horizontal and vertical acceleration. If the vertical acceleration value is not provided, the vertical acceleration is set to the same value as the horizontal acceleration. + * @param x The horizontal acceleration + * @param y The vertical acceleration Default x. + */ + setAcceleration(x: number, y?: number): this; + /** + * Sets the body's horizontal acceleration. + * @param value The horizontal acceleration + */ + setAccelerationX(value: number): this; + /** + * Sets the body's vertical acceleration. + * @param value The vertical acceleration + */ + setAccelerationY(value: number): this; + } + + /** + * Provides methods used for setting the angular acceleration properties of an Arcade Physics Body. + */ + interface Angular { + /** + * Sets the angular velocity of the body. + * + * In Arcade Physics, bodies cannot rotate. They are always axis-aligned. + * However, they can have angular motion, which is passed on to the Game Object bound to the body, + * causing them to visually rotate, even though the body remains axis-aligned. + * @param value The amount of angular velocity. + */ + setAngularVelocity(value: number): this; + /** + * Sets the angular acceleration of the body. + * + * In Arcade Physics, bodies cannot rotate. They are always axis-aligned. + * However, they can have angular motion, which is passed on to the Game Object bound to the body, + * causing them to visually rotate, even though the body remains axis-aligned. + * @param value The amount of angular acceleration. + */ + setAngularAcceleration(value: number): this; + /** + * Sets the angular drag of the body. Drag is applied to the current velocity, providing a form of deceleration. + * @param value The amount of drag. + */ + setAngularDrag(value: number): this; + } + + /** + * Provides methods used for setting the bounce properties of an Arcade Physics Body. + */ + interface Bounce { + /** + * Sets the bounce values of this body. + * + * Bounce is the amount of restitution, or elasticity, the body has when it collides with another object. + * A value of 1 means that it will retain its full velocity after the rebound. A value of 0 means it will not rebound at all. + * @param x The amount of horizontal bounce to apply on collision. A float, typically between 0 and 1. + * @param y The amount of vertical bounce to apply on collision. A float, typically between 0 and 1. Default x. + */ + setBounce(x: number, y?: number): this; + /** + * Sets the horizontal bounce value for this body. + * @param value The amount of horizontal bounce to apply on collision. A float, typically between 0 and 1. + */ + setBounceX(value: number): this; + /** + * Sets the vertical bounce value for this body. + * @param value The amount of vertical bounce to apply on collision. A float, typically between 0 and 1. + */ + setBounceY(value: number): this; + /** + * Sets whether this Body collides with the world boundary. + * + * Optionally also sets the World Bounce values. If the `Body.worldBounce` is null, it's set to a new Phaser.Math.Vector2 first. + * @param value `true` if this body should collide with the world bounds, otherwise `false`. Default true. + * @param bounceX If given this will be replace the `worldBounce.x` value. + * @param bounceY If given this will be replace the `worldBounce.y` value. + */ + setCollideWorldBounds(value?: boolean, bounceX?: number, bounceY?: number): this; + } + + /** + * Provides methods used for setting the debug properties of an Arcade Physics Body. + */ + interface Debug { + /** + * Sets the debug values of this body. + * + * Bodies will only draw their debug if debug has been enabled for Arcade Physics as a whole. + * Note that there is a performance cost in drawing debug displays. It should never be used in production. + * @param showBody Set to `true` to have this body render its outline to the debug display. + * @param showVelocity Set to `true` to have this body render a velocity marker to the debug display. + * @param bodyColor The color of the body outline when rendered to the debug display. + */ + setDebug(showBody: boolean, showVelocity: boolean, bodyColor: number): this; + /** + * Sets the color of the body outline when it renders to the debug display. + * @param value The color of the body outline when rendered to the debug display. + */ + setDebugBodyColor(value: number): this; + /** + * Set to `true` to have this body render its outline to the debug display. + */ + debugShowBody: boolean; + /** + * Set to `true` to have this body render a velocity marker to the debug display. + */ + debugShowVelocity: boolean; + /** + * The color of the body outline when it renders to the debug display. + */ + debugBodyColor: number; + } + + /** + * Provides methods used for setting the drag properties of an Arcade Physics Body. + */ + interface Drag { + /** + * Sets the body's horizontal and vertical drag. If the vertical drag value is not provided, the vertical drag is set to the same value as the horizontal drag. + * + * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. + * It is the absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. + * @param x The amount of horizontal drag to apply. + * @param y The amount of vertical drag to apply. Default x. + */ + setDrag(x: number, y?: number): this; + /** + * Sets the body's horizontal drag. + * + * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. + * It is the absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. + * @param value The amount of horizontal drag to apply. + */ + setDragX(value: number): this; + /** + * Sets the body's vertical drag. + * + * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. + * It is the absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. + * @param value The amount of vertical drag to apply. + */ + setDragY(value: number): this; + /** + * If this Body is using `drag` for deceleration this function controls how the drag is applied. + * If set to `true` drag will use a damping effect rather than a linear approach. If you are + * creating a game where the Body moves freely at any angle (i.e. like the way the ship moves in + * the game Asteroids) then you will get a far smoother and more visually correct deceleration + * by using damping, avoiding the axis-drift that is prone with linear deceleration. + * + * If you enable this property then you should use far smaller `drag` values than with linear, as + * they are used as a multiplier on the velocity. Values such as 0.95 will give a nice slow + * deceleration, where-as smaller values, such as 0.5 will stop an object almost immediately. + * @param value `true` to use damping for deceleration, or `false` to use linear deceleration. + */ + setDamping(value: boolean): this; + } + + /** + * Provides methods used for setting the enable properties of an Arcade Physics Body. + */ + interface Enable { + /** + * Enables this Game Object's Body. + * @param reset Also reset the Body and place it at (x, y). + * @param x The horizontal position to place the Game Object and Body. + * @param y The horizontal position to place the Game Object and Body. + * @param enableGameObject Also activate this Game Object. + * @param showGameObject Also show this Game Object. + */ + enableBody(reset: boolean, x: number, y: number, enableGameObject: boolean, showGameObject: boolean): this; + /** + * Stops and disables this Game Object's Body. + * @param disableGameObject Also deactivate this Game Object. Default false. + * @param hideGameObject Also hide this Game Object. Default false. + */ + disableBody(disableGameObject?: boolean, hideGameObject?: boolean): this; + /** + * Syncs the Body's position and size with its parent Game Object. + * You don't need to call this for Dynamic Bodies, as it happens automatically. + * But for Static bodies it's a useful way of modifying the position of a Static Body + * in the Physics World, based on its Game Object. + */ + refreshBody(): this; + } + + /** + * Methods for setting the friction of an Arcade Physics Body. + * + * In Arcade Physics, friction is a special case of motion transfer from an "immovable" body to a riding body. + */ + interface Friction { + /** + * Sets the friction of this game object's physics body. + * In Arcade Physics, friction is a special case of motion transfer from an "immovable" body to a riding body. + * @param x The amount of horizontal friction to apply, [0, 1]. + * @param y The amount of vertical friction to apply, [0, 1]. Default x. + */ + setFriction(x: number, y?: number): this; + /** + * Sets the horizontal friction of this game object's physics body. + * This can move a riding body horizontally when it collides with this one on the vertical axis. + * @param x The amount of friction to apply, [0, 1]. + */ + setFrictionX(x: number): this; + /** + * Sets the vertical friction of this game object's physics body. + * This can move a riding body vertically when it collides with this one on the horizontal axis. + * @param y The amount of friction to apply, [0, 1]. + */ + setFrictionY(y: number): this; + } + + /** + * Provides methods for setting the gravity properties of an Arcade Physics Game Object. + * Should be applied as a mixin and not used directly. + */ + interface Gravity { + /** + * Set the X and Y values of the gravitational pull to act upon this Arcade Physics Game Object. Values can be positive or negative. Larger values result in a stronger effect. + * + * If only one value is provided, this value will be used for both the X and Y axis. + * @param x The gravitational force to be applied to the X-axis. + * @param y The gravitational force to be applied to the Y-axis. If this is not specified, the X value will be used. Default x. + */ + setGravity(x: number, y?: number): this; + /** + * Set the gravitational force to be applied to the X axis. Value can be positive or negative. Larger values result in a stronger effect. + * @param x The gravitational force to be applied to the X-axis. + */ + setGravityX(x: number): this; + /** + * Set the gravitational force to be applied to the Y axis. Value can be positive or negative. Larger values result in a stronger effect. + * @param y The gravitational force to be applied to the Y-axis. + */ + setGravityY(y: number): this; + } + + /** + * Provides methods used for setting the immovable properties of an Arcade Physics Body. + */ + interface Immovable { + /** + * Sets if this Body can be separated during collisions with other bodies. + * + * When a body is immovable it means it won't move at all, not even to separate it from collision + * overlap. If you just wish to prevent a body from being knocked around by other bodies, see + * the `setPushable` method instead. + * @param value Sets if this body will be separated during collisions with other bodies. Default true. + */ + setImmovable(value?: boolean): this; + } + + /** + * Provides methods used for setting the mass properties of an Arcade Physics Body. + */ + interface Mass { + /** + * Sets the mass of the physics body + * @param value New value for the mass of the body. + */ + setMass(value: number): this; + } + + /** + * This method will search the given circular area and return an array of all physics bodies that + * overlap with it. It can return either Dynamic, Static bodies or a mixture of both. + * + * A body only has to intersect with the search area to be considered, it doesn't have to be fully + * contained within it. + * + * If Arcade Physics is set to use the RTree (which it is by default) then the search is rather fast, + * otherwise the search is O(N) for Dynamic Bodies. + */ + interface OverlapCirc { + } + + /** + * This method will search the given rectangular area and return an array of all physics bodies that + * overlap with it. It can return either Dynamic, Static bodies or a mixture of both. + * + * A body only has to intersect with the search area to be considered, it doesn't have to be fully + * contained within it. + * + * If Arcade Physics is set to use the RTree (which it is by default) then the search for is extremely fast, + * otherwise the search is O(N) for Dynamic Bodies. + */ + interface OverlapRect { + } + + /** + * Provides methods used for setting the pushable property of an Arcade Physics Body. + */ + interface Pushable { + /** + * Sets if this Body can be pushed by another Body. + * + * A body that cannot be pushed will reflect back all of the velocity it is given to the + * colliding body. If that body is also not pushable, then the separation will be split + * between them evenly. + * + * If you want your body to never move or seperate at all, see the `setImmovable` method. + * @param value Sets if this body can be pushed by collisions with another Body. Default true. + */ + setPushable(value?: boolean): this; + } + + /** + * Provides methods for setting the size of an Arcade Physics Game Object. + * Should be applied as a mixin and not used directly. + */ + interface Size { + /** + * Sets the body offset. This allows you to adjust the difference between the center of the body + * and the x and y coordinates of the parent Game Object. + * @param x The amount to offset the body from the parent Game Object along the x-axis. + * @param y The amount to offset the body from the parent Game Object along the y-axis. Defaults to the value given for the x-axis. Default x. + */ + setOffset(x: number, y?: number): this; + /** + * **DEPRECATED**: Please use `setBodySize` instead. + * + * Sets the size of this physics body. Setting the size does not adjust the dimensions of the parent Game Object. + * @param width The new width of the physics body, in pixels. + * @param height The new height of the physics body, in pixels. + * @param center Should the body be re-positioned so its center aligns with the parent Game Object? Default true. + */ + setSize(width: number, height: number, center?: boolean): this; + /** + * Sets the size of this physics body. Setting the size does not adjust the dimensions of the parent Game Object. + * @param width The new width of the physics body, in pixels. + * @param height The new height of the physics body, in pixels. + * @param center Should the body be re-positioned so its center aligns with the parent Game Object? Default true. + */ + setBodySize(width: number, height: number, center?: boolean): this; + /** + * Sets this physics body to use a circle for collision instead of a rectangle. + * @param radius The radius of the physics body, in pixels. + * @param offsetX The amount to offset the body from the parent Game Object along the x-axis. + * @param offsetY The amount to offset the body from the parent Game Object along the y-axis. + */ + setCircle(radius: number, offsetX?: number, offsetY?: number): this; + } + + /** + * Provides methods for modifying the velocity of an Arcade Physics body. + * + * Should be applied as a mixin and not used directly. + */ + interface Velocity { + /** + * Sets the velocity of the Body. + * @param x The horizontal velocity of the body. Positive values move the body to the right, while negative values move it to the left. + * @param y The vertical velocity of the body. Positive values move the body down, while negative values move it up. Default x. + */ + setVelocity(x: number, y?: number): this; + /** + * Sets the horizontal component of the body's velocity. + * + * Positive values move the body to the right, while negative values move it to the left. + * @param x The new horizontal velocity. + */ + setVelocityX(x: number): this; + /** + * Sets the vertical component of the body's velocity. + * + * Positive values move the body down, while negative values move it up. + * @param y The new vertical velocity of the body. + */ + setVelocityY(y: number): this; + /** + * Sets the maximum velocity of the body. + * @param x The new maximum horizontal velocity. + * @param y The new maximum vertical velocity. Default x. + */ + setMaxVelocity(x: number, y?: number): this; + } + + } + + /** + * Dynamic Body. + */ + var DYNAMIC_BODY: number; + + /** + * Static Body. + */ + var STATIC_BODY: number; + + /** + * Arcade Physics Group containing Dynamic Bodies. + */ + var GROUP: number; + + /** + * A Tilemap Layer. + */ + var TILEMAPLAYER: number; + + /** + * Facing no direction (initial value). + */ + var FACING_NONE: number; + + /** + * Facing up. + */ + var FACING_UP: number; + + /** + * Facing down. + */ + var FACING_DOWN: number; + + /** + * Facing left. + */ + var FACING_LEFT: number; + + /** + * Facing right. + */ + var FACING_RIGHT: number; + + namespace Events { + /** + * The Arcade Physics World Collide Event. + * + * This event is dispatched by an Arcade Physics World instance if two bodies collide _and_ at least + * one of them has their [onCollide]{@link Phaser.Physics.Arcade.Body#onCollide} property set to `true`. + * + * It provides an alternative means to handling collide events rather than using the callback approach. + * + * Listen to it from a Scene using: `this.physics.world.on('collide', listener)`. + * + * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. + */ + const COLLIDE: any; + + /** + * The Arcade Physics World Overlap Event. + * + * This event is dispatched by an Arcade Physics World instance if two bodies overlap _and_ at least + * one of them has their [onOverlap]{@link Phaser.Physics.Arcade.Body#onOverlap} property set to `true`. + * + * It provides an alternative means to handling overlap events rather than using the callback approach. + * + * Listen to it from a Scene using: `this.physics.world.on('overlap', listener)`. + * + * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. + */ + const OVERLAP: any; + + /** + * The Arcade Physics World Pause Event. + * + * This event is dispatched by an Arcade Physics World instance when it is paused. + * + * Listen to it from a Scene using: `this.physics.world.on('pause', listener)`. + */ + const PAUSE: any; + + /** + * The Arcade Physics World Resume Event. + * + * This event is dispatched by an Arcade Physics World instance when it resumes from a paused state. + * + * Listen to it from a Scene using: `this.physics.world.on('resume', listener)`. + */ + const RESUME: any; + + /** + * The Arcade Physics Tile Collide Event. + * + * This event is dispatched by an Arcade Physics World instance if a body collides with a Tile _and_ + * has its [onCollide]{@link Phaser.Physics.Arcade.Body#onCollide} property set to `true`. + * + * It provides an alternative means to handling collide events rather than using the callback approach. + * + * Listen to it from a Scene using: `this.physics.world.on('tilecollide', listener)`. + * + * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. + */ + const TILE_COLLIDE: any; + + /** + * The Arcade Physics Tile Overlap Event. + * + * This event is dispatched by an Arcade Physics World instance if a body overlaps with a Tile _and_ + * has its [onOverlap]{@link Phaser.Physics.Arcade.Body#onOverlap} property set to `true`. + * + * It provides an alternative means to handling overlap events rather than using the callback approach. + * + * Listen to it from a Scene using: `this.physics.world.on('tileoverlap', listener)`. + * + * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. + */ + const TILE_OVERLAP: any; + + /** + * The Arcade Physics World Bounds Event. + * + * This event is dispatched by an Arcade Physics World instance if a body makes contact with the world bounds _and_ + * it has its [onWorldBounds]{@link Phaser.Physics.Arcade.Body#onWorldBounds} property set to `true`. + * + * It provides an alternative means to handling collide events rather than using the callback approach. + * + * Listen to it from a Scene using: `this.physics.world.on('worldbounds', listener)`. + */ + const WORLD_BOUNDS: any; + + /** + * The Arcade Physics World Step Event. + * + * This event is dispatched by an Arcade Physics World instance whenever a physics step is run. + * It is emitted _after_ the bodies and colliders have been updated. + * + * In high framerate settings this can be multiple times per game frame. + * + * Listen to it from a Scene using: `this.physics.world.on('worldstep', listener)`. + */ + const WORLD_STEP: any; + + } + + namespace Tilemap { + /** + * A function to process the collision callbacks between a single tile and an Arcade Physics enabled Game Object. + * @param tile The Tile to process. + * @param sprite The Game Object to process with the Tile. + */ + function ProcessTileCallbacks(tile: Phaser.Tilemaps.Tile, sprite: Phaser.GameObjects.Sprite): boolean; + + /** + * Internal function to process the separation of a physics body from a tile. + * @param body The Body object to separate. + * @param x The x separation amount. + */ + function ProcessTileSeparationX(body: Phaser.Physics.Arcade.Body, x: number): void; + + /** + * Internal function to process the separation of a physics body from a tile. + * @param body The Body object to separate. + * @param y The y separation amount. + */ + function ProcessTileSeparationY(body: Phaser.Physics.Arcade.Body, y: number): void; + + /** + * The core separation function to separate a physics body and a tile. + * @param i The index of the tile within the map data. + * @param body The Body object to separate. + * @param tile The tile to collide against. + * @param tileWorldRect A rectangle-like object defining the dimensions of the tile. + * @param tilemapLayer The tilemapLayer to collide against. + * @param tileBias The tile bias value. Populated by the `World.TILE_BIAS` constant. + * @param isLayer Is this check coming from a TilemapLayer or an array of tiles? + */ + function SeparateTile(i: number, body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileWorldRect: Phaser.Geom.Rectangle, tilemapLayer: Phaser.Tilemaps.TilemapLayer, tileBias: number, isLayer: boolean): boolean; + + /** + * Check the body against the given tile on the X axis. + * Used internally by the SeparateTile function. + * @param body The Body object to separate. + * @param tile The tile to check. + * @param tileLeft The left position of the tile within the tile world. + * @param tileRight The right position of the tile within the tile world. + * @param tileBias The tile bias value. Populated by the `World.TILE_BIAS` constant. + * @param isLayer Is this check coming from a TilemapLayer or an array of tiles? + */ + function TileCheckX(body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileLeft: number, tileRight: number, tileBias: number, isLayer: boolean): number; + + /** + * Check the body against the given tile on the Y axis. + * Used internally by the SeparateTile function. + * @param body The Body object to separate. + * @param tile The tile to check. + * @param tileTop The top position of the tile within the tile world. + * @param tileBottom The bottom position of the tile within the tile world. + * @param tileBias The tile bias value. Populated by the `World.TILE_BIAS` constant. + * @param isLayer Is this check coming from a TilemapLayer or an array of tiles? + */ + function TileCheckY(body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileTop: number, tileBottom: number, tileBias: number, isLayer: boolean): number; + + /** + * Checks for intersection between the given tile rectangle-like object and an Arcade Physics body. + * @param tileWorldRect A rectangle object that defines the tile placement in the world. + * @param body The body to check for intersection against. + */ + function TileIntersectsBody(tileWorldRect: Object, body: Phaser.Physics.Arcade.Body): boolean; + + } + } namespace Matter { @@ -73126,743 +73139,9 @@ declare namespace Phaser { } - namespace Components { - /** - * A component to set restitution on objects. - */ - interface Bounce { - /** - * Sets the restitution on the physics object. - * @param value A Number that defines the restitution (elasticity) of the body. The value is always positive and is in the range (0, 1). A value of 0 means collisions may be perfectly inelastic and no bouncing may occur. A value of 0.8 means the body may bounce back with approximately 80% of its kinetic energy. Note that collision response is based on pairs of bodies, and that restitution values are combined with the following formula: `Math.max(bodyA.restitution, bodyB.restitution)` - */ - setBounce(value: number): Phaser.GameObjects.GameObject; - } - - /** - * Contains methods for changing the collision filter of a Matter Body. Should be used as a mixin and not called directly. - */ - interface Collision { - /** - * Sets the collision category of this Game Object's Matter Body. This number must be a power of two between 2^0 (= 1) and 2^31. - * Two bodies with different collision groups (see {@link #setCollisionGroup}) will only collide if their collision - * categories are included in their collision masks (see {@link #setCollidesWith}). - * @param value Unique category bitfield. - */ - setCollisionCategory(value: number): Phaser.GameObjects.GameObject; - /** - * Sets the collision group of this Game Object's Matter Body. If this is zero or two Matter Bodies have different values, - * they will collide according to the usual rules (see {@link #setCollisionCategory} and {@link #setCollisionGroup}). - * If two Matter Bodies have the same positive value, they will always collide; if they have the same negative value, - * they will never collide. - * @param value Unique group index. - */ - setCollisionGroup(value: number): Phaser.GameObjects.GameObject; - /** - * Sets the collision mask for this Game Object's Matter Body. Two Matter Bodies with different collision groups will only - * collide if each one includes the other's category in its mask based on a bitwise AND, i.e. `(categoryA & maskB) !== 0` - * and `(categoryB & maskA) !== 0` are both true. - * @param categories A unique category bitfield, or an array of them. - */ - setCollidesWith(categories: number | number[]): Phaser.GameObjects.GameObject; - /** - * The callback is sent a `Phaser.Types.Physics.Matter.MatterCollisionData` object. - * - * This does not change the bodies collision category, group or filter. Those must be set in addition - * to the callback. - * @param callback The callback to invoke when this body starts colliding with another. - */ - setOnCollide(callback: Function): Phaser.GameObjects.GameObject; - /** - * The callback is sent a `Phaser.Types.Physics.Matter.MatterCollisionData` object. - * - * This does not change the bodies collision category, group or filter. Those must be set in addition - * to the callback. - * @param callback The callback to invoke when this body stops colliding with another. - */ - setOnCollideEnd(callback: Function): Phaser.GameObjects.GameObject; - /** - * The callback is sent a `Phaser.Types.Physics.Matter.MatterCollisionData` object. - * - * This does not change the bodies collision category, group or filter. Those must be set in addition - * to the callback. - * @param callback The callback to invoke for the duration of this body colliding with another. - */ - setOnCollideActive(callback: Function): Phaser.GameObjects.GameObject; - /** - * The callback is sent a reference to the other body, along with a `Phaser.Types.Physics.Matter.MatterCollisionData` object. - * - * This does not change the bodies collision category, group or filter. Those must be set in addition - * to the callback. - * @param body The body, or an array of bodies, to test for collisions with. - * @param callback The callback to invoke when this body collides with the given body or bodies. - */ - setOnCollideWith(body: MatterJS.Body | MatterJS.Body[], callback: Function): Phaser.GameObjects.GameObject; - } - - /** - * A component to apply force to Matter.js bodies. - */ - interface Force { - /** - * Applies a force to a body. - * @param force A Vector that specifies the force to apply. - */ - applyForce(force: Phaser.Math.Vector2): Phaser.GameObjects.GameObject; - /** - * Applies a force to a body from a given position. - * @param position The position in which the force comes from. - * @param force A Vector that specifies the force to apply. - */ - applyForceFrom(position: Phaser.Math.Vector2, force: Phaser.Math.Vector2): Phaser.GameObjects.GameObject; - /** - * Apply thrust to the forward position of the body. - * - * Use very small values, such as 0.1, depending on the mass and required speed. - * @param speed A speed value to be applied to a directional force. - */ - thrust(speed: number): Phaser.GameObjects.GameObject; - /** - * Apply thrust to the left position of the body. - * - * Use very small values, such as 0.1, depending on the mass and required speed. - * @param speed A speed value to be applied to a directional force. - */ - thrustLeft(speed: number): Phaser.GameObjects.GameObject; - /** - * Apply thrust to the right position of the body. - * - * Use very small values, such as 0.1, depending on the mass and required speed. - * @param speed A speed value to be applied to a directional force. - */ - thrustRight(speed: number): Phaser.GameObjects.GameObject; - /** - * Apply thrust to the back position of the body. - * - * Use very small values, such as 0.1, depending on the mass and required speed. - * @param speed A speed value to be applied to a directional force. - */ - thrustBack(speed: number): Phaser.GameObjects.GameObject; - } - - /** - * Contains methods for changing the friction of a Game Object's Matter Body. Should be used a mixin, not called directly. - */ - interface Friction { - /** - * Sets new friction values for this Game Object's Matter Body. - * @param value The new friction of the body, between 0 and 1, where 0 allows the Body to slide indefinitely, while 1 allows it to stop almost immediately after a force is applied. - * @param air If provided, the new air resistance of the Body. The higher the value, the faster the Body will slow as it moves through space. 0 means the body has no air resistance. - * @param fstatic If provided, the new static friction of the Body. The higher the value (e.g. 10), the more force it will take to initially get the Body moving when it is nearly stationary. 0 means the body will never "stick" when it is nearly stationary. - */ - setFriction(value: number, air?: number, fstatic?: number): Phaser.GameObjects.GameObject; - /** - * Sets a new air resistance for this Game Object's Matter Body. - * A value of 0 means the Body will never slow as it moves through space. - * The higher the value, the faster a Body slows when moving through space. - * @param value The new air resistance for the Body. - */ - setFrictionAir(value: number): Phaser.GameObjects.GameObject; - /** - * Sets a new static friction for this Game Object's Matter Body. - * A value of 0 means the Body will never "stick" when it is nearly stationary. - * The higher the value (e.g. 10), the more force it will take to initially get the Body moving when it is nearly stationary. - * @param value The new static friction for the Body. - */ - setFrictionStatic(value: number): Phaser.GameObjects.GameObject; - } - - /** - * A component to manipulate world gravity for Matter.js bodies. - */ - interface Gravity { - /** - * A togglable function for ignoring world gravity in real-time on the current body. - * @param value Set to true to ignore the effect of world gravity, or false to not ignore it. - */ - setIgnoreGravity(value: boolean): Phaser.GameObjects.GameObject; - } - - /** - * Allows accessing the mass, density, and center of mass of a Matter-enabled Game Object. Should be used as a mixin and not directly. - */ - interface Mass { - /** - * Sets the mass of the Game Object's Matter Body. - * @param value The new mass of the body. - */ - setMass(value: number): Phaser.GameObjects.GameObject; - /** - * Sets density of the body. - * @param value The new density of the body. - */ - setDensity(value: number): Phaser.GameObjects.GameObject; - /** - * The body's center of mass. - * - * Calling this creates a new `Vector2 each time to avoid mutation. - * - * If you only need to read the value and won't change it, you can get it from `GameObject.body.centerOfMass`. - */ - readonly centerOfMass: Phaser.Math.Vector2; - } - - /** - * Enables a Matter-enabled Game Object to be a sensor. Should be used as a mixin and not directly. - */ - interface Sensor { - /** - * Set the body belonging to this Game Object to be a sensor. - * Sensors trigger collision events, but don't react with colliding body physically. - * @param value `true` to set the body as a sensor, or `false` to disable it. - */ - setSensor(value: boolean): Phaser.GameObjects.GameObject; - /** - * Is the body belonging to this Game Object a sensor or not? - */ - isSensor(): boolean; - } - - /** - * Enables a Matter-enabled Game Object to set its Body. Should be used as a mixin and not directly. - */ - interface SetBody { - /** - * Set the body on a Game Object to a rectangle. - * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. - * @param width Width of the rectangle. - * @param height Height of the rectangle. - * @param options An optional Body configuration object that is used to set initial Body properties on creation. - */ - setRectangle(width: number, height: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): Phaser.GameObjects.GameObject; - /** - * Set the body on a Game Object to a circle. - * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. - * @param radius The radius of the circle. - * @param options An optional Body configuration object that is used to set initial Body properties on creation. - */ - setCircle(radius: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): Phaser.GameObjects.GameObject; - /** - * Set the body on the Game Object to a polygon shape. - * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. - * @param radius The "radius" of the polygon, i.e. the distance from its center to any vertex. This is also the radius of its circumcircle. - * @param sides The number of sides the polygon will have. - * @param options An optional Body configuration object that is used to set initial Body properties on creation. - */ - setPolygon(radius: number, sides: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): Phaser.GameObjects.GameObject; - /** - * Set the body on the Game Object to a trapezoid shape. - * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. - * @param width The width of the trapezoid Body. - * @param height The height of the trapezoid Body. - * @param slope The slope of the trapezoid. 0 creates a rectangle, while 1 creates a triangle. Positive values make the top side shorter, while negative values make the bottom side shorter. - * @param options An optional Body configuration object that is used to set initial Body properties on creation. - */ - setTrapezoid(width: number, height: number, slope: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): Phaser.GameObjects.GameObject; - /** - * Set this Game Object to use the given existing Matter Body. - * - * The body is first removed from the world before being added to this Game Object. - * @param body The Body this Game Object should use. - * @param addToWorld Should the body be immediately added to the World? Default true. - */ - setExistingBody(body: MatterJS.BodyType, addToWorld?: boolean): Phaser.GameObjects.GameObject; - /** - * Set this Game Object to create and use a new Body based on the configuration object given. - * - * Calling this method resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. - * @param config Either a string, such as `circle`, or a Matter Set Body Configuration object. - * @param options An optional Body configuration object that is used to set initial Body properties on creation. - */ - setBody(config: string | Phaser.Types.Physics.Matter.MatterSetBodyConfig, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): Phaser.GameObjects.GameObject; - } - - /** - * Enables a Matter-enabled Game Object to be able to go to sleep. Should be used as a mixin and not directly. - */ - interface Sleep { - /** - * Sets this Body to sleep. - */ - setToSleep(): this; - /** - * Wakes this Body if asleep. - */ - setAwake(): this; - /** - * Sets the number of updates in which this body must have near-zero velocity before it is set as sleeping (if sleeping is enabled by the engine). - * @param value A `Number` that defines the number of updates in which this body must have near-zero velocity before it is set as sleeping. Default 60. - */ - setSleepThreshold(value?: number): this; - /** - * Enable sleep and wake events for this body. - * - * By default when a body goes to sleep, or wakes up, it will not emit any events. - * - * The events are emitted by the Matter World instance and can be listened to via - * the `SLEEP_START` and `SLEEP_END` events. - * @param start `true` if you want the sleep start event to be emitted for this body. - * @param end `true` if you want the sleep end event to be emitted for this body. - */ - setSleepEvents(start: boolean, end: boolean): this; - /** - * Enables or disables the Sleep Start event for this body. - * @param value `true` to enable the sleep event, or `false` to disable it. - */ - setSleepStartEvent(value: boolean): this; - /** - * Enables or disables the Sleep End event for this body. - * @param value `true` to enable the sleep event, or `false` to disable it. - */ - setSleepEndEvent(value: boolean): this; - } - - /** - * Provides methods used for getting and setting the static state of a physics body. - */ - interface Static { - /** - * Changes the physics body to be either static `true` or dynamic `false`. - * @param value `true` to set the body as being static, or `false` to make it dynamic. - */ - setStatic(value: boolean): Phaser.GameObjects.GameObject; - /** - * Returns `true` if the body is static, otherwise `false` for a dynamic body. - */ - isStatic(): boolean; - } - - /** - * Provides methods used for getting and setting the position, scale and rotation of a Game Object. - */ - interface Transform { - /** - * The x position of this Game Object. - */ - x: number; - /** - * The y position of this Game Object. - */ - y: number; - /** - * The horizontal scale of this Game Object. - */ - scaleX: number; - /** - * The vertical scale of this Game Object. - */ - scaleY: number; - /** - * Use `angle` to set or get rotation of the physics body associated to this GameObject. - * Unlike rotation, when using set the value can be in degrees, which will be converted to radians internally. - */ - angle: number; - /** - * Use `rotation` to set or get the rotation of the physics body associated with this GameObject. - * The value when set must be in radians. - */ - rotation: number; - /** - * Sets the position of the physics body along x and y axes. - * Both the parameters to this function are optional and if not passed any they default to 0. - * Velocity, angle, force etc. are unchanged. - * @param x The horizontal position of the body. Default 0. - * @param y The vertical position of the body. Default x. - */ - setPosition(x?: number, y?: number): this; - /** - * Immediately sets the angle of the Body. - * Angular velocity, position, force etc. are unchanged. - * @param radians The angle of the body, in radians. Default 0. - */ - setRotation(radians?: number): this; - /** - * Setting fixed rotation sets the Body inertia to Infinity, which stops it - * from being able to rotate when forces are applied to it. - */ - setFixedRotation(): this; - /** - * Immediately sets the angle of the Body. - * Angular velocity, position, force etc. are unchanged. - * @param degrees The angle to set, in degrees. Default 0. - */ - setAngle(degrees?: number): this; - /** - * Sets the scale of this Game Object. - * @param x The horizontal scale of this Game Object. Default 1. - * @param y The vertical scale of this Game Object. If not set it will use the x value. Default x. - * @param point The point (Vector2) from which scaling will occur. - */ - setScale(x?: number, y?: number, point?: Phaser.Math.Vector2): this; - } - - /** - * Contains methods for changing the velocity of a Matter Body. Should be used as a mixin and not called directly. - */ - interface Velocity { - /** - * Sets the angular velocity of the body instantly. - * Position, angle, force etc. are unchanged. - * @param value The angular velocity. - */ - setAngularVelocity(value: number): Phaser.GameObjects.GameObject; - /** - * Sets the horizontal velocity of the physics body. - * @param x The horizontal velocity value. - */ - setVelocityX(x: number): Phaser.GameObjects.GameObject; - /** - * Sets vertical velocity of the physics body. - * @param y The vertical velocity value. - */ - setVelocityY(y: number): Phaser.GameObjects.GameObject; - /** - * Sets both the horizontal and vertical velocity of the physics body. - * @param x The horizontal velocity value. - * @param y The vertical velocity value, it can be either positive or negative. If not given, it will be the same as the `x` value. Default x. - */ - setVelocity(x: number, y?: number): Phaser.GameObjects.GameObject; - } - - } - namespace Matter { } - namespace Events { - type AfterAddEvent = { - /** - * An array of the object(s) that have been added. May be a single body, constraint, composite or a mixture of these. - */ - object: any[]; - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; - - /** - * The Matter Physics After Add Event. - * - * This event is dispatched by a Matter Physics World instance at the end of the process when a new Body - * or Constraint has just been added to the world. - * - * Listen to it from a Scene using: `this.matter.world.on('afteradd', listener)`. - */ - const AFTER_ADD: any; - - type AfterRemoveEvent = { - /** - * An array of the object(s) that were removed. May be a single body, constraint, composite or a mixture of these. - */ - object: any[]; - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; - - /** - * The Matter Physics After Remove Event. - * - * This event is dispatched by a Matter Physics World instance at the end of the process when a - * Body or Constraint was removed from the world. - * - * Listen to it from a Scene using: `this.matter.world.on('afterremove', listener)`. - */ - const AFTER_REMOVE: any; - - type AfterUpdateEvent = { - /** - * The Matter Engine `timing.timestamp` value for the event. - */ - timestamp: number; - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; - - /** - * The Matter Physics After Update Event. - * - * This event is dispatched by a Matter Physics World instance after the engine has updated and all collision events have resolved. - * - * Listen to it from a Scene using: `this.matter.world.on('afterupdate', listener)`. - */ - const AFTER_UPDATE: any; - - type BeforeAddEvent = { - /** - * An array of the object(s) to be added. May be a single body, constraint, composite or a mixture of these. - */ - object: any[]; - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; - - /** - * The Matter Physics Before Add Event. - * - * This event is dispatched by a Matter Physics World instance at the start of the process when a new Body - * or Constraint is being added to the world. - * - * Listen to it from a Scene using: `this.matter.world.on('beforeadd', listener)`. - */ - const BEFORE_ADD: any; - - type BeforeRemoveEvent = { - /** - * An array of the object(s) to be removed. May be a single body, constraint, composite or a mixture of these. - */ - object: any[]; - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; - - /** - * The Matter Physics Before Remove Event. - * - * This event is dispatched by a Matter Physics World instance at the start of the process when a - * Body or Constraint is being removed from the world. - * - * Listen to it from a Scene using: `this.matter.world.on('beforeremove', listener)`. - */ - const BEFORE_REMOVE: any; - - type BeforeUpdateEvent = { - /** - * The Matter Engine `timing.timestamp` value for the event. - */ - timestamp: number; - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; - - /** - * The Matter Physics Before Update Event. - * - * This event is dispatched by a Matter Physics World instance right before all the collision processing takes place. - * - * Listen to it from a Scene using: `this.matter.world.on('beforeupdate', listener)`. - */ - const BEFORE_UPDATE: any; - - type CollisionActiveEvent = { - /** - * A list of all affected pairs in the collision. - */ - pairs: Phaser.Types.Physics.Matter.MatterCollisionData[]; - /** - * The Matter Engine `timing.timestamp` value for the event. - */ - timestamp: number; - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; - - /** - * The Matter Physics Collision Active Event. - * - * This event is dispatched by a Matter Physics World instance after the engine has updated. - * It provides a list of all pairs that are colliding in the current tick (if any). - * - * Listen to it from a Scene using: `this.matter.world.on('collisionactive', listener)`. - */ - const COLLISION_ACTIVE: any; - - type CollisionEndEvent = { - /** - * A list of all affected pairs in the collision. - */ - pairs: Phaser.Types.Physics.Matter.MatterCollisionData[]; - /** - * The Matter Engine `timing.timestamp` value for the event. - */ - timestamp: number; - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; - - /** - * The Matter Physics Collision End Event. - * - * This event is dispatched by a Matter Physics World instance after the engine has updated. - * It provides a list of all pairs that have finished colliding in the current tick (if any). - * - * Listen to it from a Scene using: `this.matter.world.on('collisionend', listener)`. - */ - const COLLISION_END: any; - - type CollisionStartEvent = { - /** - * A list of all affected pairs in the collision. - */ - pairs: Phaser.Types.Physics.Matter.MatterCollisionData[]; - /** - * The Matter Engine `timing.timestamp` value for the event. - */ - timestamp: number; - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; - - /** - * The Matter Physics Collision Start Event. - * - * This event is dispatched by a Matter Physics World instance after the engine has updated. - * It provides a list of all pairs that have started to collide in the current tick (if any). - * - * Listen to it from a Scene using: `this.matter.world.on('collisionstart', listener)`. - */ - const COLLISION_START: any; - - /** - * The Matter Physics Drag End Event. - * - * This event is dispatched by a Matter Physics World instance when a Pointer Constraint - * stops dragging a body. - * - * Listen to it from a Scene using: `this.matter.world.on('dragend', listener)`. - */ - const DRAG_END: any; - - /** - * The Matter Physics Drag Event. - * - * This event is dispatched by a Matter Physics World instance when a Pointer Constraint - * is actively dragging a body. It is emitted each time the pointer moves. - * - * Listen to it from a Scene using: `this.matter.world.on('drag', listener)`. - */ - const DRAG: any; - - /** - * The Matter Physics Drag Start Event. - * - * This event is dispatched by a Matter Physics World instance when a Pointer Constraint - * starts dragging a body. - * - * Listen to it from a Scene using: `this.matter.world.on('dragstart', listener)`. - */ - const DRAG_START: any; - - /** - * The Matter Physics World Pause Event. - * - * This event is dispatched by an Matter Physics World instance when it is paused. - * - * Listen to it from a Scene using: `this.matter.world.on('pause', listener)`. - */ - const PAUSE: any; - - /** - * The Matter Physics World Resume Event. - * - * This event is dispatched by an Matter Physics World instance when it resumes from a paused state. - * - * Listen to it from a Scene using: `this.matter.world.on('resume', listener)`. - */ - const RESUME: any; - - type SleepEndEvent = { - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; - - /** - * The Matter Physics Sleep End Event. - * - * This event is dispatched by a Matter Physics World instance when a Body stop sleeping. - * - * Listen to it from a Scene using: `this.matter.world.on('sleepend', listener)`. - */ - const SLEEP_END: any; - - type SleepStartEvent = { - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; - - /** - * The Matter Physics Sleep Start Event. - * - * This event is dispatched by a Matter Physics World instance when a Body goes to sleep. - * - * Listen to it from a Scene using: `this.matter.world.on('sleepstart', listener)`. - */ - const SLEEP_START: any; - - } - /** * The Matter Factory is responsible for quickly creating a variety of different types of * bodies, constraints and Game Objects and adding them into the physics world. @@ -78641,6 +77920,740 @@ declare namespace Phaser { } + namespace Components { + /** + * A component to set restitution on objects. + */ + interface Bounce { + /** + * Sets the restitution on the physics object. + * @param value A Number that defines the restitution (elasticity) of the body. The value is always positive and is in the range (0, 1). A value of 0 means collisions may be perfectly inelastic and no bouncing may occur. A value of 0.8 means the body may bounce back with approximately 80% of its kinetic energy. Note that collision response is based on pairs of bodies, and that restitution values are combined with the following formula: `Math.max(bodyA.restitution, bodyB.restitution)` + */ + setBounce(value: number): Phaser.GameObjects.GameObject; + } + + /** + * Contains methods for changing the collision filter of a Matter Body. Should be used as a mixin and not called directly. + */ + interface Collision { + /** + * Sets the collision category of this Game Object's Matter Body. This number must be a power of two between 2^0 (= 1) and 2^31. + * Two bodies with different collision groups (see {@link #setCollisionGroup}) will only collide if their collision + * categories are included in their collision masks (see {@link #setCollidesWith}). + * @param value Unique category bitfield. + */ + setCollisionCategory(value: number): Phaser.GameObjects.GameObject; + /** + * Sets the collision group of this Game Object's Matter Body. If this is zero or two Matter Bodies have different values, + * they will collide according to the usual rules (see {@link #setCollisionCategory} and {@link #setCollisionGroup}). + * If two Matter Bodies have the same positive value, they will always collide; if they have the same negative value, + * they will never collide. + * @param value Unique group index. + */ + setCollisionGroup(value: number): Phaser.GameObjects.GameObject; + /** + * Sets the collision mask for this Game Object's Matter Body. Two Matter Bodies with different collision groups will only + * collide if each one includes the other's category in its mask based on a bitwise AND, i.e. `(categoryA & maskB) !== 0` + * and `(categoryB & maskA) !== 0` are both true. + * @param categories A unique category bitfield, or an array of them. + */ + setCollidesWith(categories: number | number[]): Phaser.GameObjects.GameObject; + /** + * The callback is sent a `Phaser.Types.Physics.Matter.MatterCollisionData` object. + * + * This does not change the bodies collision category, group or filter. Those must be set in addition + * to the callback. + * @param callback The callback to invoke when this body starts colliding with another. + */ + setOnCollide(callback: Function): Phaser.GameObjects.GameObject; + /** + * The callback is sent a `Phaser.Types.Physics.Matter.MatterCollisionData` object. + * + * This does not change the bodies collision category, group or filter. Those must be set in addition + * to the callback. + * @param callback The callback to invoke when this body stops colliding with another. + */ + setOnCollideEnd(callback: Function): Phaser.GameObjects.GameObject; + /** + * The callback is sent a `Phaser.Types.Physics.Matter.MatterCollisionData` object. + * + * This does not change the bodies collision category, group or filter. Those must be set in addition + * to the callback. + * @param callback The callback to invoke for the duration of this body colliding with another. + */ + setOnCollideActive(callback: Function): Phaser.GameObjects.GameObject; + /** + * The callback is sent a reference to the other body, along with a `Phaser.Types.Physics.Matter.MatterCollisionData` object. + * + * This does not change the bodies collision category, group or filter. Those must be set in addition + * to the callback. + * @param body The body, or an array of bodies, to test for collisions with. + * @param callback The callback to invoke when this body collides with the given body or bodies. + */ + setOnCollideWith(body: MatterJS.Body | MatterJS.Body[], callback: Function): Phaser.GameObjects.GameObject; + } + + /** + * A component to apply force to Matter.js bodies. + */ + interface Force { + /** + * Applies a force to a body. + * @param force A Vector that specifies the force to apply. + */ + applyForce(force: Phaser.Math.Vector2): Phaser.GameObjects.GameObject; + /** + * Applies a force to a body from a given position. + * @param position The position in which the force comes from. + * @param force A Vector that specifies the force to apply. + */ + applyForceFrom(position: Phaser.Math.Vector2, force: Phaser.Math.Vector2): Phaser.GameObjects.GameObject; + /** + * Apply thrust to the forward position of the body. + * + * Use very small values, such as 0.1, depending on the mass and required speed. + * @param speed A speed value to be applied to a directional force. + */ + thrust(speed: number): Phaser.GameObjects.GameObject; + /** + * Apply thrust to the left position of the body. + * + * Use very small values, such as 0.1, depending on the mass and required speed. + * @param speed A speed value to be applied to a directional force. + */ + thrustLeft(speed: number): Phaser.GameObjects.GameObject; + /** + * Apply thrust to the right position of the body. + * + * Use very small values, such as 0.1, depending on the mass and required speed. + * @param speed A speed value to be applied to a directional force. + */ + thrustRight(speed: number): Phaser.GameObjects.GameObject; + /** + * Apply thrust to the back position of the body. + * + * Use very small values, such as 0.1, depending on the mass and required speed. + * @param speed A speed value to be applied to a directional force. + */ + thrustBack(speed: number): Phaser.GameObjects.GameObject; + } + + /** + * Contains methods for changing the friction of a Game Object's Matter Body. Should be used a mixin, not called directly. + */ + interface Friction { + /** + * Sets new friction values for this Game Object's Matter Body. + * @param value The new friction of the body, between 0 and 1, where 0 allows the Body to slide indefinitely, while 1 allows it to stop almost immediately after a force is applied. + * @param air If provided, the new air resistance of the Body. The higher the value, the faster the Body will slow as it moves through space. 0 means the body has no air resistance. + * @param fstatic If provided, the new static friction of the Body. The higher the value (e.g. 10), the more force it will take to initially get the Body moving when it is nearly stationary. 0 means the body will never "stick" when it is nearly stationary. + */ + setFriction(value: number, air?: number, fstatic?: number): Phaser.GameObjects.GameObject; + /** + * Sets a new air resistance for this Game Object's Matter Body. + * A value of 0 means the Body will never slow as it moves through space. + * The higher the value, the faster a Body slows when moving through space. + * @param value The new air resistance for the Body. + */ + setFrictionAir(value: number): Phaser.GameObjects.GameObject; + /** + * Sets a new static friction for this Game Object's Matter Body. + * A value of 0 means the Body will never "stick" when it is nearly stationary. + * The higher the value (e.g. 10), the more force it will take to initially get the Body moving when it is nearly stationary. + * @param value The new static friction for the Body. + */ + setFrictionStatic(value: number): Phaser.GameObjects.GameObject; + } + + /** + * A component to manipulate world gravity for Matter.js bodies. + */ + interface Gravity { + /** + * A togglable function for ignoring world gravity in real-time on the current body. + * @param value Set to true to ignore the effect of world gravity, or false to not ignore it. + */ + setIgnoreGravity(value: boolean): Phaser.GameObjects.GameObject; + } + + /** + * Allows accessing the mass, density, and center of mass of a Matter-enabled Game Object. Should be used as a mixin and not directly. + */ + interface Mass { + /** + * Sets the mass of the Game Object's Matter Body. + * @param value The new mass of the body. + */ + setMass(value: number): Phaser.GameObjects.GameObject; + /** + * Sets density of the body. + * @param value The new density of the body. + */ + setDensity(value: number): Phaser.GameObjects.GameObject; + /** + * The body's center of mass. + * + * Calling this creates a new `Vector2 each time to avoid mutation. + * + * If you only need to read the value and won't change it, you can get it from `GameObject.body.centerOfMass`. + */ + readonly centerOfMass: Phaser.Math.Vector2; + } + + /** + * Enables a Matter-enabled Game Object to be a sensor. Should be used as a mixin and not directly. + */ + interface Sensor { + /** + * Set the body belonging to this Game Object to be a sensor. + * Sensors trigger collision events, but don't react with colliding body physically. + * @param value `true` to set the body as a sensor, or `false` to disable it. + */ + setSensor(value: boolean): Phaser.GameObjects.GameObject; + /** + * Is the body belonging to this Game Object a sensor or not? + */ + isSensor(): boolean; + } + + /** + * Enables a Matter-enabled Game Object to set its Body. Should be used as a mixin and not directly. + */ + interface SetBody { + /** + * Set the body on a Game Object to a rectangle. + * + * Calling this methods resets previous properties you may have set on the body, including + * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * @param width Width of the rectangle. + * @param height Height of the rectangle. + * @param options An optional Body configuration object that is used to set initial Body properties on creation. + */ + setRectangle(width: number, height: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): Phaser.GameObjects.GameObject; + /** + * Set the body on a Game Object to a circle. + * + * Calling this methods resets previous properties you may have set on the body, including + * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * @param radius The radius of the circle. + * @param options An optional Body configuration object that is used to set initial Body properties on creation. + */ + setCircle(radius: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): Phaser.GameObjects.GameObject; + /** + * Set the body on the Game Object to a polygon shape. + * + * Calling this methods resets previous properties you may have set on the body, including + * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * @param radius The "radius" of the polygon, i.e. the distance from its center to any vertex. This is also the radius of its circumcircle. + * @param sides The number of sides the polygon will have. + * @param options An optional Body configuration object that is used to set initial Body properties on creation. + */ + setPolygon(radius: number, sides: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): Phaser.GameObjects.GameObject; + /** + * Set the body on the Game Object to a trapezoid shape. + * + * Calling this methods resets previous properties you may have set on the body, including + * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * @param width The width of the trapezoid Body. + * @param height The height of the trapezoid Body. + * @param slope The slope of the trapezoid. 0 creates a rectangle, while 1 creates a triangle. Positive values make the top side shorter, while negative values make the bottom side shorter. + * @param options An optional Body configuration object that is used to set initial Body properties on creation. + */ + setTrapezoid(width: number, height: number, slope: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): Phaser.GameObjects.GameObject; + /** + * Set this Game Object to use the given existing Matter Body. + * + * The body is first removed from the world before being added to this Game Object. + * @param body The Body this Game Object should use. + * @param addToWorld Should the body be immediately added to the World? Default true. + */ + setExistingBody(body: MatterJS.BodyType, addToWorld?: boolean): Phaser.GameObjects.GameObject; + /** + * Set this Game Object to create and use a new Body based on the configuration object given. + * + * Calling this method resets previous properties you may have set on the body, including + * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * @param config Either a string, such as `circle`, or a Matter Set Body Configuration object. + * @param options An optional Body configuration object that is used to set initial Body properties on creation. + */ + setBody(config: string | Phaser.Types.Physics.Matter.MatterSetBodyConfig, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): Phaser.GameObjects.GameObject; + } + + /** + * Enables a Matter-enabled Game Object to be able to go to sleep. Should be used as a mixin and not directly. + */ + interface Sleep { + /** + * Sets this Body to sleep. + */ + setToSleep(): this; + /** + * Wakes this Body if asleep. + */ + setAwake(): this; + /** + * Sets the number of updates in which this body must have near-zero velocity before it is set as sleeping (if sleeping is enabled by the engine). + * @param value A `Number` that defines the number of updates in which this body must have near-zero velocity before it is set as sleeping. Default 60. + */ + setSleepThreshold(value?: number): this; + /** + * Enable sleep and wake events for this body. + * + * By default when a body goes to sleep, or wakes up, it will not emit any events. + * + * The events are emitted by the Matter World instance and can be listened to via + * the `SLEEP_START` and `SLEEP_END` events. + * @param start `true` if you want the sleep start event to be emitted for this body. + * @param end `true` if you want the sleep end event to be emitted for this body. + */ + setSleepEvents(start: boolean, end: boolean): this; + /** + * Enables or disables the Sleep Start event for this body. + * @param value `true` to enable the sleep event, or `false` to disable it. + */ + setSleepStartEvent(value: boolean): this; + /** + * Enables or disables the Sleep End event for this body. + * @param value `true` to enable the sleep event, or `false` to disable it. + */ + setSleepEndEvent(value: boolean): this; + } + + /** + * Provides methods used for getting and setting the static state of a physics body. + */ + interface Static { + /** + * Changes the physics body to be either static `true` or dynamic `false`. + * @param value `true` to set the body as being static, or `false` to make it dynamic. + */ + setStatic(value: boolean): Phaser.GameObjects.GameObject; + /** + * Returns `true` if the body is static, otherwise `false` for a dynamic body. + */ + isStatic(): boolean; + } + + /** + * Provides methods used for getting and setting the position, scale and rotation of a Game Object. + */ + interface Transform { + /** + * The x position of this Game Object. + */ + x: number; + /** + * The y position of this Game Object. + */ + y: number; + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + /** + * Use `angle` to set or get rotation of the physics body associated to this GameObject. + * Unlike rotation, when using set the value can be in degrees, which will be converted to radians internally. + */ + angle: number; + /** + * Use `rotation` to set or get the rotation of the physics body associated with this GameObject. + * The value when set must be in radians. + */ + rotation: number; + /** + * Sets the position of the physics body along x and y axes. + * Both the parameters to this function are optional and if not passed any they default to 0. + * Velocity, angle, force etc. are unchanged. + * @param x The horizontal position of the body. Default 0. + * @param y The vertical position of the body. Default x. + */ + setPosition(x?: number, y?: number): this; + /** + * Immediately sets the angle of the Body. + * Angular velocity, position, force etc. are unchanged. + * @param radians The angle of the body, in radians. Default 0. + */ + setRotation(radians?: number): this; + /** + * Setting fixed rotation sets the Body inertia to Infinity, which stops it + * from being able to rotate when forces are applied to it. + */ + setFixedRotation(): this; + /** + * Immediately sets the angle of the Body. + * Angular velocity, position, force etc. are unchanged. + * @param degrees The angle to set, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. Default 1. + * @param y The vertical scale of this Game Object. If not set it will use the x value. Default x. + * @param point The point (Vector2) from which scaling will occur. + */ + setScale(x?: number, y?: number, point?: Phaser.Math.Vector2): this; + } + + /** + * Contains methods for changing the velocity of a Matter Body. Should be used as a mixin and not called directly. + */ + interface Velocity { + /** + * Sets the angular velocity of the body instantly. + * Position, angle, force etc. are unchanged. + * @param value The angular velocity. + */ + setAngularVelocity(value: number): Phaser.GameObjects.GameObject; + /** + * Sets the horizontal velocity of the physics body. + * @param x The horizontal velocity value. + */ + setVelocityX(x: number): Phaser.GameObjects.GameObject; + /** + * Sets vertical velocity of the physics body. + * @param y The vertical velocity value. + */ + setVelocityY(y: number): Phaser.GameObjects.GameObject; + /** + * Sets both the horizontal and vertical velocity of the physics body. + * @param x The horizontal velocity value. + * @param y The vertical velocity value, it can be either positive or negative. If not given, it will be the same as the `x` value. Default x. + */ + setVelocity(x: number, y?: number): Phaser.GameObjects.GameObject; + } + + } + + namespace Events { + type AfterAddEvent = { + /** + * An array of the object(s) that have been added. May be a single body, constraint, composite or a mixture of these. + */ + object: any[]; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics After Add Event. + * + * This event is dispatched by a Matter Physics World instance at the end of the process when a new Body + * or Constraint has just been added to the world. + * + * Listen to it from a Scene using: `this.matter.world.on('afteradd', listener)`. + */ + const AFTER_ADD: any; + + type AfterRemoveEvent = { + /** + * An array of the object(s) that were removed. May be a single body, constraint, composite or a mixture of these. + */ + object: any[]; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics After Remove Event. + * + * This event is dispatched by a Matter Physics World instance at the end of the process when a + * Body or Constraint was removed from the world. + * + * Listen to it from a Scene using: `this.matter.world.on('afterremove', listener)`. + */ + const AFTER_REMOVE: any; + + type AfterUpdateEvent = { + /** + * The Matter Engine `timing.timestamp` value for the event. + */ + timestamp: number; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics After Update Event. + * + * This event is dispatched by a Matter Physics World instance after the engine has updated and all collision events have resolved. + * + * Listen to it from a Scene using: `this.matter.world.on('afterupdate', listener)`. + */ + const AFTER_UPDATE: any; + + type BeforeAddEvent = { + /** + * An array of the object(s) to be added. May be a single body, constraint, composite or a mixture of these. + */ + object: any[]; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics Before Add Event. + * + * This event is dispatched by a Matter Physics World instance at the start of the process when a new Body + * or Constraint is being added to the world. + * + * Listen to it from a Scene using: `this.matter.world.on('beforeadd', listener)`. + */ + const BEFORE_ADD: any; + + type BeforeRemoveEvent = { + /** + * An array of the object(s) to be removed. May be a single body, constraint, composite or a mixture of these. + */ + object: any[]; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics Before Remove Event. + * + * This event is dispatched by a Matter Physics World instance at the start of the process when a + * Body or Constraint is being removed from the world. + * + * Listen to it from a Scene using: `this.matter.world.on('beforeremove', listener)`. + */ + const BEFORE_REMOVE: any; + + type BeforeUpdateEvent = { + /** + * The Matter Engine `timing.timestamp` value for the event. + */ + timestamp: number; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics Before Update Event. + * + * This event is dispatched by a Matter Physics World instance right before all the collision processing takes place. + * + * Listen to it from a Scene using: `this.matter.world.on('beforeupdate', listener)`. + */ + const BEFORE_UPDATE: any; + + type CollisionActiveEvent = { + /** + * A list of all affected pairs in the collision. + */ + pairs: Phaser.Types.Physics.Matter.MatterCollisionData[]; + /** + * The Matter Engine `timing.timestamp` value for the event. + */ + timestamp: number; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics Collision Active Event. + * + * This event is dispatched by a Matter Physics World instance after the engine has updated. + * It provides a list of all pairs that are colliding in the current tick (if any). + * + * Listen to it from a Scene using: `this.matter.world.on('collisionactive', listener)`. + */ + const COLLISION_ACTIVE: any; + + type CollisionEndEvent = { + /** + * A list of all affected pairs in the collision. + */ + pairs: Phaser.Types.Physics.Matter.MatterCollisionData[]; + /** + * The Matter Engine `timing.timestamp` value for the event. + */ + timestamp: number; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics Collision End Event. + * + * This event is dispatched by a Matter Physics World instance after the engine has updated. + * It provides a list of all pairs that have finished colliding in the current tick (if any). + * + * Listen to it from a Scene using: `this.matter.world.on('collisionend', listener)`. + */ + const COLLISION_END: any; + + type CollisionStartEvent = { + /** + * A list of all affected pairs in the collision. + */ + pairs: Phaser.Types.Physics.Matter.MatterCollisionData[]; + /** + * The Matter Engine `timing.timestamp` value for the event. + */ + timestamp: number; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics Collision Start Event. + * + * This event is dispatched by a Matter Physics World instance after the engine has updated. + * It provides a list of all pairs that have started to collide in the current tick (if any). + * + * Listen to it from a Scene using: `this.matter.world.on('collisionstart', listener)`. + */ + const COLLISION_START: any; + + /** + * The Matter Physics Drag End Event. + * + * This event is dispatched by a Matter Physics World instance when a Pointer Constraint + * stops dragging a body. + * + * Listen to it from a Scene using: `this.matter.world.on('dragend', listener)`. + */ + const DRAG_END: any; + + /** + * The Matter Physics Drag Event. + * + * This event is dispatched by a Matter Physics World instance when a Pointer Constraint + * is actively dragging a body. It is emitted each time the pointer moves. + * + * Listen to it from a Scene using: `this.matter.world.on('drag', listener)`. + */ + const DRAG: any; + + /** + * The Matter Physics Drag Start Event. + * + * This event is dispatched by a Matter Physics World instance when a Pointer Constraint + * starts dragging a body. + * + * Listen to it from a Scene using: `this.matter.world.on('dragstart', listener)`. + */ + const DRAG_START: any; + + /** + * The Matter Physics World Pause Event. + * + * This event is dispatched by an Matter Physics World instance when it is paused. + * + * Listen to it from a Scene using: `this.matter.world.on('pause', listener)`. + */ + const PAUSE: any; + + /** + * The Matter Physics World Resume Event. + * + * This event is dispatched by an Matter Physics World instance when it resumes from a paused state. + * + * Listen to it from a Scene using: `this.matter.world.on('resume', listener)`. + */ + const RESUME: any; + + type SleepEndEvent = { + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics Sleep End Event. + * + * This event is dispatched by a Matter Physics World instance when a Body stop sleeping. + * + * Listen to it from a Scene using: `this.matter.world.on('sleepend', listener)`. + */ + const SLEEP_END: any; + + type SleepStartEvent = { + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics Sleep Start Event. + * + * This event is dispatched by a Matter Physics World instance when a Body goes to sleep. + * + * Listen to it from a Scene using: `this.matter.world.on('sleepstart', listener)`. + */ + const SLEEP_START: any; + + } + } } @@ -79334,6 +79347,24 @@ declare namespace Phaser { XOR, } + /** + * Phaser Scale Modes. + */ + enum ScaleModes { + /** + * Default Scale Mode (Linear). + */ + DEFAULT, + /** + * Linear Scale Mode. + */ + LINEAR, + /** + * Nearest Scale Mode. + */ + NEAREST, + } + namespace Renderer { namespace Canvas { /** @@ -79666,41 +79697,6 @@ declare namespace Phaser { } namespace WebGL { - /** - * 8-bit twos complement signed integer. - */ - var BYTE: Phaser.Types.Renderer.WebGL.WebGLConst; - - /** - * 8-bit twos complement unsigned integer. - */ - var UNSIGNED_BYTE: Phaser.Types.Renderer.WebGL.WebGLConst; - - /** - * 16-bit twos complement signed integer. - */ - var SHORT: Phaser.Types.Renderer.WebGL.WebGLConst; - - /** - * 16-bit twos complement unsigned integer. - */ - var UNSIGNED_SHORT: Phaser.Types.Renderer.WebGL.WebGLConst; - - /** - * 32-bit twos complement signed integer. - */ - var INT: Phaser.Types.Renderer.WebGL.WebGLConst; - - /** - * 32-bit twos complement unsigned integer. - */ - var UNSIGNED_INT: Phaser.Types.Renderer.WebGL.WebGLConst; - - /** - * 32-bit IEEE floating point number. - */ - var FLOAT: Phaser.Types.Renderer.WebGL.WebGLConst; - /** * The Pipeline Manager is responsible for the creation, activation, running and destruction * of WebGL Pipelines and Post FX Pipelines in Phaser 3. @@ -80165,1216 +80161,6 @@ declare namespace Phaser { } - namespace Pipelines { - /** - * The Bitmap Mask Pipeline handles all of the bitmap mask rendering in WebGL for applying - * alpha masks to Game Objects. It works by sampling two texture on the fragment shader and - * using the fragments alpha to clip the region. - * - * The fragment shader it uses can be found in `shaders/src/BitmapMask.frag`. - * The vertex shader it uses can be found in `shaders/src/BitmapMask.vert`. - * - * The default shader attributes for this pipeline are: - * - * `inPosition` (vec2, offset 0) - * - * The default shader uniforms for this pipeline are: - * - * `uResolution` (vec2) - * `uMainSampler` (sampler2D) - * `uMaskSampler` (sampler2D) - * `uInvertMaskAlpha` (bool) - */ - class BitmapMaskPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - - /** - * Binds necessary resources and renders the mask to a separated framebuffer. - * The framebuffer for the masked object is also bound for further use. - * @param mask GameObject used as mask. - * @param maskedObject GameObject masked by the mask GameObject. - * @param camera The camera rendering the current mask. - */ - beginMask(mask: Phaser.GameObjects.GameObject, maskedObject: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * The masked game objects framebuffer is unbound and its texture - * is bound together with the mask texture and the mask shader and - * a draw call with a single quad is processed. Here is where the - * masking effect is applied. - * @param mask GameObject used as a mask. - */ - endMask(mask: Phaser.GameObjects.GameObject): void; - - } - - /** - * The Bitmap Mask Pipeline. - */ - const BITMAPMASK_PIPELINE: string; - - /** - * The Light 2D Pipeline. - */ - const LIGHT_PIPELINE: string; - - /** - * The Point Light Pipeline. - */ - const POINTLIGHT_PIPELINE: string; - - /** - * The Single Texture Pipeline. - */ - const SINGLE_PIPELINE: string; - - /** - * The Multi Texture Pipeline. - */ - const MULTI_PIPELINE: string; - - /** - * The Rope Pipeline. - */ - const ROPE_PIPELINE: string; - - /** - * The Graphics and Shapes Pipeline. - */ - const GRAPHICS_PIPELINE: string; - - /** - * The Post FX Pipeline. - */ - const POSTFX_PIPELINE: string; - - /** - * The Utility Pipeline. - */ - const UTILITY_PIPELINE: string; - - namespace Events { - /** - * The WebGLPipeline After Flush Event. - * - * This event is dispatched by a WebGLPipeline right after it has issued a drawArrays command - * and cleared its vertex count. - */ - const AFTER_FLUSH: any; - - /** - * The WebGLPipeline Before Flush Event. - * - * This event is dispatched by a WebGLPipeline right before it is about to - * flush and issue a bufferData and drawArrays command. - */ - const BEFORE_FLUSH: any; - - /** - * The WebGLPipeline Bind Event. - * - * This event is dispatched by a WebGLPipeline when it is bound by the Pipeline Manager. - */ - const BIND: any; - - /** - * The WebGLPipeline Boot Event. - * - * This event is dispatched by a WebGLPipeline when it has completed its `boot` phase. - */ - const BOOT: any; - - /** - * The WebGLPipeline Destroy Event. - * - * This event is dispatched by a WebGLPipeline when it is starting its destroy process. - */ - const DESTROY: any; - - /** - * The WebGLPipeline ReBind Event. - * - * This event is dispatched by a WebGLPipeline when it is re-bound by the Pipeline Manager. - */ - const REBIND: any; - - /** - * The WebGLPipeline Resize Event. - * - * This event is dispatched by a WebGLPipeline when it is resized, usually as a result - * of the Renderer resizing. - */ - const RESIZE: any; - - } - - /** - * The Graphics Pipeline is the rendering pipeline used by Phaser in WebGL when drawing - * primitive geometry objects, such as the Graphics Game Object, or the Shape Game Objects - * such as Arc, Line, Rectangle and Star. It handles the preperation and batching of related vertices. - * - * Prior to Phaser v3.50 the functions of this pipeline were merged with the `TextureTintPipeline`. - * - * The fragment shader it uses can be found in `shaders/src/Graphics.frag`. - * The vertex shader it uses can be found in `shaders/src/Graphics.vert`. - * - * The default shader attributes for this pipeline are: - * - * `inPosition` (vec2) - * `inColor` (vec4, normalized) - * - * The default shader uniforms for this pipeline are: - * - * `uProjectionMatrix` (mat4) - */ - class GraphicsPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - - /** - * A temporary Transform Matrix, re-used internally during batching by the - * Shape Game Objects. - */ - calcMatrix: Phaser.GameObjects.Components.TransformMatrix; - - /** - * Pushes a filled rectangle into the vertex batch. - * - * Rectangle factors in the given transform matrices before adding to the batch. - * @param x Horizontal top left coordinate of the rectangle. - * @param y Vertical top left coordinate of the rectangle. - * @param width Width of the rectangle. - * @param height Height of the rectangle. - * @param currentMatrix The current transform. - * @param parentMatrix The parent transform. - */ - batchFillRect(x: number, y: number, width: number, height: number, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Pushes a filled triangle into the vertex batch. - * - * Triangle factors in the given transform matrices before adding to the batch. - * @param x0 Point 0 x coordinate. - * @param y0 Point 0 y coordinate. - * @param x1 Point 1 x coordinate. - * @param y1 Point 1 y coordinate. - * @param x2 Point 2 x coordinate. - * @param y2 Point 2 y coordinate. - * @param currentMatrix The current transform. - * @param parentMatrix The parent transform. - */ - batchFillTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Pushes a stroked triangle into the vertex batch. - * - * Triangle factors in the given transform matrices before adding to the batch. - * - * The triangle is created from 3 lines and drawn using the `batchStrokePath` method. - * @param x0 Point 0 x coordinate. - * @param y0 Point 0 y coordinate. - * @param x1 Point 1 x coordinate. - * @param y1 Point 1 y coordinate. - * @param x2 Point 2 x coordinate. - * @param y2 Point 2 y coordinate. - * @param lineWidth The width of the line in pixels. - * @param currentMatrix The current transform. - * @param parentMatrix The parent transform. - */ - batchStrokeTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, lineWidth: number, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Adds the given path to the vertex batch for rendering. - * - * It works by taking the array of path data and then passing it through Earcut, which - * creates a list of polygons. Each polygon is then added to the batch. - * - * The path is always automatically closed because it's filled. - * @param path Collection of points that represent the path. - * @param currentMatrix The current transform. - * @param parentMatrix The parent transform. - */ - batchFillPath(path: Phaser.Types.Math.Vector2Like[], currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Adds the given path to the vertex batch for rendering. - * - * It works by taking the array of path data and calling `batchLine` for each section - * of the path. - * - * The path is optionally closed at the end. - * @param path Collection of points that represent the path. - * @param lineWidth The width of the line segments in pixels. - * @param pathOpen Indicates if the path should be closed or left open. - * @param currentMatrix The current transform. - * @param parentMatrix The parent transform. - */ - batchStrokePath(path: Phaser.Types.Math.Vector2Like[], lineWidth: number, pathOpen: boolean, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Creates a line out of 4 quads and adds it to the vertex batch based on the given line values. - * @param ax x coordinate of the start of the line. - * @param ay y coordinate of the start of the line. - * @param bx x coordinate of the end of the line. - * @param by y coordinate of the end of the line. - * @param aLineWidth Width of the start of the line. - * @param bLineWidth Width of the end of the line. - * @param index If this line is part of a multi-line draw, the index of the line in the draw. - * @param closePath Does this line close a multi-line path? - * @param currentMatrix The current transform. - * @param parentMatrix The parent transform. - */ - batchLine(ax: number, ay: number, bx: number, by: number, aLineWidth: number, bLineWidth: number, index: number, closePath: boolean, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Adds a single vertex to the current vertex buffer and increments the - * `vertexCount` property by 1. - * - * This method is called directly by `batchTri` and `batchQuad`. - * - * It does not perform any batch limit checking itself, so if you need to call - * this method directly, do so in the same way that `batchQuad` does, for example. - * @param x The vertex x position. - * @param y The vertex y position. - * @param tint The tint color value. - */ - batchVert(x: number, y: number, tint: number): void; - - /** - * Destroys all shader instances, removes all object references and nulls all external references. - */ - destroy(): this; - - } - - /** - * The Light Pipeline is an extension of the Multi Pipeline and uses a custom shader - * designed to handle forward diffused rendering of 2D lights in a Scene. - * - * The shader works in tandem with Light Game Objects, and optionally texture normal maps, - * to provide an ambient illumination effect. - * - * If you wish to provide your own shader, you can use the `%LIGHT_COUNT%` declaration in the source, - * and it will be automatically replaced at run-time with the total number of configured lights. - * - * The maximum number of lights can be set in the Render Config `maxLights` property and defaults to 10. - * - * Prior to Phaser v3.50 this pipeline was called the `ForwardDiffuseLightPipeline`. - * - * The fragment shader it uses can be found in `shaders/src/Light.frag`. - * The vertex shader it uses can be found in `shaders/src/Multi.vert`. - * - * The default shader attributes for this pipeline are: - * - * `inPosition` (vec2, offset 0) - * `inTexCoord` (vec2, offset 8) - * `inTexId` (float, offset 16) - * `inTintEffect` (float, offset 20) - * `inTint` (vec4, offset 24, normalized) - * - * The default shader uniforms for this pipeline are those from the Multi Pipeline, plus: - * - * `uMainSampler` (sampler2D) - * `uNormSampler` (sampler2D) - * `uCamera` (vec4) - * `uResolution` (vec2) - * `uAmbientLightColor` (vec3) - * `uInverseRotationMatrix` (mat3) - * `uLights` (Light struct) - */ - class LightPipeline extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - - /** - * Stores a default normal map, which is an object with a `glTexture` property that - * maps to a 1x1 texture of the color #7f7fff created in the `boot` method. - */ - defaultNormalMap: object; - - /** - * A boolean that is set automatically during `onRender` that determines - * if the Scene LightManager is active, or not. - */ - readonly lightsActive: boolean; - - /** - * Called when the Game has fully booted and the Renderer has finished setting up. - * - * By this stage all Game level systems are now in place and you can perform any final - * tasks that the pipeline may need that relied on game systems such as the Texture Manager. - */ - boot(): void; - - /** - * Rotates the normal map vectors inversely by the given angle. - * Only works in 2D space. - * @param rotation The angle of rotation in radians. - */ - setNormalMapRotation(rotation: number): void; - - /** - * Returns the normal map WebGLTexture from the given Game Object. - * If the Game Object doesn't have one, it returns the default normal map from this pipeline instead. - * @param gameObject The Game Object to get the normal map from. - */ - getNormalMap(gameObject?: Phaser.GameObjects.GameObject): WebGLTexture; - - /** - * Takes a Sprite Game Object, or any object that extends it, and adds it to the batch. - * @param gameObject The texture based Game Object to add to the batch. - * @param camera The Camera to use for the rendering transform. - * @param parentTransformMatrix The transform matrix of the parent container, if set. - */ - batchSprite(gameObject: Phaser.GameObjects.Image | Phaser.GameObjects.Sprite, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Generic function for batching a textured quad using argument values instead of a Game Object. - * @param gameObject Source GameObject. - * @param texture Raw WebGLTexture associated with the quad. - * @param textureWidth Real texture width. - * @param textureHeight Real texture height. - * @param srcX X coordinate of the quad. - * @param srcY Y coordinate of the quad. - * @param srcWidth Width of the quad. - * @param srcHeight Height of the quad. - * @param scaleX X component of scale. - * @param scaleY Y component of scale. - * @param rotation Rotation of the quad. - * @param flipX Indicates if the quad is horizontally flipped. - * @param flipY Indicates if the quad is vertically flipped. - * @param scrollFactorX By which factor is the quad affected by the camera horizontal scroll. - * @param scrollFactorY By which factor is the quad effected by the camera vertical scroll. - * @param displayOriginX Horizontal origin in pixels. - * @param displayOriginY Vertical origin in pixels. - * @param frameX X coordinate of the texture frame. - * @param frameY Y coordinate of the texture frame. - * @param frameWidth Width of the texture frame. - * @param frameHeight Height of the texture frame. - * @param tintTL Tint for top left. - * @param tintTR Tint for top right. - * @param tintBL Tint for bottom left. - * @param tintBR Tint for bottom right. - * @param tintEffect The tint effect. - * @param uOffset Horizontal offset on texture coordinate. - * @param vOffset Vertical offset on texture coordinate. - * @param camera Current used camera. - * @param parentTransformMatrix Parent container. - * @param skipFlip Skip the renderTexture check. Default false. - * @param textureUnit Use the currently bound texture unit? - */ - batchTexture(gameObject: Phaser.GameObjects.GameObject, texture: WebGLTexture, textureWidth: number, textureHeight: number, srcX: number, srcY: number, srcWidth: number, srcHeight: number, scaleX: number, scaleY: number, rotation: number, flipX: boolean, flipY: boolean, scrollFactorX: number, scrollFactorY: number, displayOriginX: number, displayOriginY: number, frameX: number, frameY: number, frameWidth: number, frameHeight: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number, uOffset: number, vOffset: number, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix, skipFlip?: boolean, textureUnit?: number): void; - - /** - * Adds a Texture Frame into the batch for rendering. - * @param frame The Texture Frame to be rendered. - * @param x The horizontal position to render the texture at. - * @param y The vertical position to render the texture at. - * @param tint The tint color. - * @param alpha The alpha value. - * @param transformMatrix The Transform Matrix to use for the texture. - * @param parentTransformMatrix A parent Transform Matrix. - */ - batchTextureFrame(frame: Phaser.Textures.Frame, x: number, y: number, tint: number, alpha: number, transformMatrix: Phaser.GameObjects.Components.TransformMatrix, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; - - } - - /** - * The Multi Pipeline is the core 2D texture rendering pipeline used by Phaser in WebGL. - * Virtually all Game Objects use this pipeline by default, including Sprites, Graphics - * and Tilemaps. It handles the batching of quads and tris, as well as methods for - * drawing and batching geometry data. - * - * Prior to Phaser v3.50 this pipeline was called the `TextureTintPipeline`. - * - * In previous versions of Phaser only one single texture unit was supported at any one time. - * The Multi Pipeline is an evolution of the old Texture Tint Pipeline, updated to support - * multi-textures for increased performance. - * - * The fragment shader it uses can be found in `shaders/src/Multi.frag`. - * The vertex shader it uses can be found in `shaders/src/Multi.vert`. - * - * The default shader attributes for this pipeline are: - * - * `inPosition` (vec2, offset 0) - * `inTexCoord` (vec2, offset 8) - * `inTexId` (float, offset 16) - * `inTintEffect` (float, offset 20) - * `inTint` (vec4, offset 24, normalized) - * - * The default shader uniforms for this pipeline are: - * - * `uProjectionMatrix` (mat4) - * `uMainSampler` (sampler2D array) - * - * If you wish to create a custom pipeline extending from this one, you can use two string - * declarations in your fragment shader source: `%count%` and `%forloop%`, where `count` is - * used to set the number of `sampler2Ds` available, and `forloop` is a block of GLSL code - * that will get the currently bound texture unit. - * - * This pipeline will automatically inject that code for you, should those values exist - * in your shader source. If you wish to handle this yourself, you can also use the - * function `Utils.parseFragmentShaderMaxTextures`. - * - * If you wish to create a pipeline that works from a single texture, or that doesn't have - * internal texture iteration, please see the `SinglePipeline` instead. - */ - class MultiPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - - /** - * Called every time the pipeline is bound by the renderer. - * Sets the shader program, vertex buffer and other resources. - * Should only be called when changing pipeline. - */ - bind(): this; - - /** - * Takes a Sprite Game Object, or any object that extends it, and adds it to the batch. - * @param gameObject The texture based Game Object to add to the batch. - * @param camera The Camera to use for the rendering transform. - * @param parentTransformMatrix The transform matrix of the parent container, if set. - */ - batchSprite(gameObject: Phaser.GameObjects.Image | Phaser.GameObjects.Sprite, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Generic function for batching a textured quad using argument values instead of a Game Object. - * @param gameObject Source GameObject. - * @param texture Raw WebGLTexture associated with the quad. - * @param textureWidth Real texture width. - * @param textureHeight Real texture height. - * @param srcX X coordinate of the quad. - * @param srcY Y coordinate of the quad. - * @param srcWidth Width of the quad. - * @param srcHeight Height of the quad. - * @param scaleX X component of scale. - * @param scaleY Y component of scale. - * @param rotation Rotation of the quad. - * @param flipX Indicates if the quad is horizontally flipped. - * @param flipY Indicates if the quad is vertically flipped. - * @param scrollFactorX By which factor is the quad affected by the camera horizontal scroll. - * @param scrollFactorY By which factor is the quad effected by the camera vertical scroll. - * @param displayOriginX Horizontal origin in pixels. - * @param displayOriginY Vertical origin in pixels. - * @param frameX X coordinate of the texture frame. - * @param frameY Y coordinate of the texture frame. - * @param frameWidth Width of the texture frame. - * @param frameHeight Height of the texture frame. - * @param tintTL Tint for top left. - * @param tintTR Tint for top right. - * @param tintBL Tint for bottom left. - * @param tintBR Tint for bottom right. - * @param tintEffect The tint effect. - * @param uOffset Horizontal offset on texture coordinate. - * @param vOffset Vertical offset on texture coordinate. - * @param camera Current used camera. - * @param parentTransformMatrix Parent container. - * @param skipFlip Skip the renderTexture check. Default false. - * @param textureUnit Use the currently bound texture unit? - */ - batchTexture(gameObject: Phaser.GameObjects.GameObject, texture: WebGLTexture, textureWidth: number, textureHeight: number, srcX: number, srcY: number, srcWidth: number, srcHeight: number, scaleX: number, scaleY: number, rotation: number, flipX: boolean, flipY: boolean, scrollFactorX: number, scrollFactorY: number, displayOriginX: number, displayOriginY: number, frameX: number, frameY: number, frameWidth: number, frameHeight: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number, uOffset: number, vOffset: number, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix, skipFlip?: boolean, textureUnit?: number): void; - - /** - * Adds a Texture Frame into the batch for rendering. - * @param frame The Texture Frame to be rendered. - * @param x The horizontal position to render the texture at. - * @param y The vertical position to render the texture at. - * @param tint The tint color. - * @param alpha The alpha value. - * @param transformMatrix The Transform Matrix to use for the texture. - * @param parentTransformMatrix A parent Transform Matrix. - */ - batchTextureFrame(frame: Phaser.Textures.Frame, x: number, y: number, tint: number, alpha: number, transformMatrix: Phaser.GameObjects.Components.TransformMatrix, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; - - } - - /** - * The Point Light Pipeline handles rendering the Point Light Game Objects in WebGL. - * - * The fragment shader it uses can be found in `shaders/src/PointLight.frag`. - * The vertex shader it uses can be found in `shaders/src/PointLight.vert`. - * - * The default shader attributes for this pipeline are: - * - * `inPosition` (vec2) - * `inLightPosition` (vec2) - * `inLightRadius` (float) - * `inLightAttenuation` (float) - * `inLightColor` (vec4) - * - * The default shader uniforms for this pipeline are: - * - * `uProjectionMatrix` (mat4) - * `uResolution` (vec2) - * `uCameraZoom` (sampler2D) - */ - class PointLightPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - - /** - * Adds a Point Light Game Object to the batch, flushing if required. - * @param light The Point Light Game Object. - * @param camera The camera rendering the Point Light. - * @param x0 The top-left x position. - * @param y0 The top-left y position. - * @param x1 The bottom-left x position. - * @param y1 The bottom-left y position. - * @param x2 The bottom-right x position. - * @param y2 The bottom-right y position. - * @param x3 The top-right x position. - * @param y3 The top-right y position. - * @param lightX The horizontal center of the light. - * @param lightY The vertical center of the light. - */ - batchPointLight(light: Phaser.GameObjects.PointLight, camera: Phaser.Cameras.Scene2D.Camera, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, lightX: number, lightY: number): void; - - /** - * Adds a single Point Light vertex to the current vertex buffer and increments the - * `vertexCount` property by 1. - * - * This method is called directly by `batchPointLight`. - * @param x The vertex x position. - * @param y The vertex y position. - * @param lightX The horizontal center of the light. - * @param lightY The vertical center of the light. - * @param radius The radius of the light. - * @param attenuation The attenuation of the light. - * @param r The red color channel of the light. - * @param g The green color channel of the light. - * @param b The blue color channel of the light. - * @param a The alpha color channel of the light. - */ - batchLightVert(x: number, y: number, lightX: number, lightY: number, radius: number, attenuation: number, r: number, g: number, b: number, a: number): void; - - } - - /** - * The Post FX Pipeline is a special kind of pipeline specifically for handling post - * processing effects. Where-as a standard Pipeline allows you to control the process - * of rendering Game Objects by configuring the shaders and attributes used to draw them, - * a Post FX Pipeline is designed to allow you to apply processing _after_ the Game Object/s - * have been rendered. Typical examples of post processing effects are bloom filters, - * blurs, light effects and color manipulation. - * - * The pipeline works by creating a tiny vertex buffer with just one single hard-coded quad - * in it. Game Objects can have a Post Pipeline set on them. Those objects are then rendered - * using their standard pipeline, but are redirected to the Render Targets owned by the - * post pipeline, which can then apply their own shaders and effects, before passing them - * back to the main renderer. - * - * Please see the Phaser 3 examples for further details on this extensive subject. - * - * The default fragment shader it uses can be found in `shaders/src/PostFX.frag`. - * The default vertex shader it uses can be found in `shaders/src/Quad.vert`. - * - * The default shader attributes for this pipeline are: - * - * `inPosition` (vec2, offset 0) - * `inTexCoord` (vec2, offset 8) - * - * The vertices array layout is: - * - * -1, 1 B----C 1, 1 - * 0, 1 | /| 1, 1 - * | / | - * | / | - * |/ | - * -1, -1 A----D 1, -1 - * 0, 0 1, 0 - * - * A = -1, -1 (pos) and 0, 0 (uv) - * B = -1, 1 (pos) and 0, 1 (uv) - * C = 1, 1 (pos) and 1, 1 (uv) - * D = 1, -1 (pos) and 1, 0 (uv) - * - * First tri: A, B, C - * Second tri: A, C, D - * - * Array index: - * - * 0 = Tri 1 - Vert A - x pos - * 1 = Tri 1 - Vert A - y pos - * 2 = Tri 1 - Vert A - uv u - * 3 = Tri 1 - Vert A - uv v - * - * 4 = Tri 1 - Vert B - x pos - * 5 = Tri 1 - Vert B - y pos - * 6 = Tri 1 - Vert B - uv u - * 7 = Tri 1 - Vert B - uv v - * - * 8 = Tri 1 - Vert C - x pos - * 9 = Tri 1 - Vert C - y pos - * 10 = Tri 1 - Vert C - uv u - * 11 = Tri 1 - Vert C - uv v - * - * 12 = Tri 2 - Vert A - x pos - * 13 = Tri 2 - Vert A - y pos - * 14 = Tri 2 - Vert A - uv u - * 15 = Tri 2 - Vert A - uv v - * - * 16 = Tri 2 - Vert C - x pos - * 17 = Tri 2 - Vert C - y pos - * 18 = Tri 2 - Vert C - uv u - * 19 = Tri 2 - Vert C - uv v - * - * 20 = Tri 2 - Vert D - x pos - * 21 = Tri 2 - Vert D - y pos - * 22 = Tri 2 - Vert D - uv u - * 23 = Tri 2 - Vert D - uv v - */ - class PostFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - - /** - * If this post-pipeline belongs to a Game Object or Camera, this contains a reference to it. - */ - gameObject: Phaser.GameObjects.GameObject; - - /** - * A Color Matrix instance belonging to this pipeline. - * - * Used during calls to the `drawFrame` method. - */ - colorMatrix: Phaser.Display.ColorMatrix; - - /** - * A reference to the Full Frame 1 Render Target that belongs to the - * Utility Pipeline. This property is set during the `boot` method. - * - * This Render Target is the full size of the renderer. - * - * You can use this directly in Post FX Pipelines for multi-target effects. - * However, be aware that these targets are shared between all post fx pipelines. - */ - fullFrame1: Phaser.Renderer.WebGL.RenderTarget; - - /** - * A reference to the Full Frame 2 Render Target that belongs to the - * Utility Pipeline. This property is set during the `boot` method. - * - * This Render Target is the full size of the renderer. - * - * You can use this directly in Post FX Pipelines for multi-target effects. - * However, be aware that these targets are shared between all post fx pipelines. - */ - fullFrame2: Phaser.Renderer.WebGL.RenderTarget; - - /** - * A reference to the Half Frame 1 Render Target that belongs to the - * Utility Pipeline. This property is set during the `boot` method. - * - * This Render Target is half the size of the renderer. - * - * You can use this directly in Post FX Pipelines for multi-target effects. - * However, be aware that these targets are shared between all post fx pipelines. - */ - halfFrame1: Phaser.Renderer.WebGL.RenderTarget; - - /** - * A reference to the Half Frame 2 Render Target that belongs to the - * Utility Pipeline. This property is set during the `boot` method. - * - * This Render Target is half the size of the renderer. - * - * You can use this directly in Post FX Pipelines for multi-target effects. - * However, be aware that these targets are shared between all post fx pipelines. - */ - halfFrame2: Phaser.Renderer.WebGL.RenderTarget; - - /** - * Copy the `source` Render Target to the `target` Render Target. - * - * You can optionally set the brightness factor of the copy. - * - * The difference between this method and `drawFrame` is that this method - * uses a faster copy shader, where only the brightness can be modified. - * If you need color level manipulation, see `drawFrame` instead. - * @param source The source Render Target. - * @param target The target Render Target. - * @param brightness The brightness value applied to the frame copy. Default 1. - * @param clear Clear the target before copying? Default true. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - copyFrame(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean): void; - - /** - * Pops the framebuffer from the renderers FBO stack and sets that as the active target, - * then draws the `source` Render Target to it. It then resets the renderer textures. - * - * This should be done when you need to draw the _final_ results of a pipeline to the game - * canvas, or the next framebuffer in line on the FBO stack. You should only call this once - * in the `onDraw` handler and it should be the final thing called. Be careful not to call - * this if you need to actually use the pipeline shader, instead of the copy shader. In - * those cases, use the `bindAndDraw` method. - * @param source The Render Target to draw from. - */ - copyToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; - - /** - * Copy the `source` Render Target to the `target` Render Target, using the - * given Color Matrix. - * - * The difference between this method and `copyFrame` is that this method - * uses a color matrix shader, where you have full control over the luminance - * values used during the copy. If you don't need this, you can use the faster - * `copyFrame` method instead. - * @param source The source Render Target. - * @param target The target Render Target. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - drawFrame(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean): void; - - /** - * Draws the `source1` and `source2` Render Targets to the `target` Render Target - * using a linear blend effect, which is controlled by the `strength` parameter. - * @param source1 The first source Render Target. - * @param source2 The second source Render Target. - * @param target The target Render Target. - * @param strength The strength of the blend. Default 1. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - blendFrames(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): void; - - /** - * Draws the `source1` and `source2` Render Targets to the `target` Render Target - * using an additive blend effect, which is controlled by the `strength` parameter. - * @param source1 The first source Render Target. - * @param source2 The second source Render Target. - * @param target The target Render Target. - * @param strength The strength of the blend. Default 1. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - blendFramesAdditive(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): void; - - /** - * Clears the given Render Target. - * @param target The Render Target to clear. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - clearFrame(target: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean): void; - - /** - * Copy the `source` Render Target to the `target` Render Target. - * - * The difference with this copy is that no resizing takes place. If the `source` - * Render Target is larger than the `target` then only a portion the same size as - * the `target` dimensions is copied across. - * - * You can optionally set the brightness factor of the copy. - * @param source The source Render Target. - * @param target The target Render Target. - * @param brightness The brightness value applied to the frame copy. Default 1. - * @param clear Clear the target before copying? Default true. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - * @param eraseMode Erase source from target using ERASE Blend Mode? Default false. - */ - blitFrame(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean): void; - - /** - * Binds the `source` Render Target and then copies a section of it to the `target` Render Target. - * - * This method is extremely fast because it uses `gl.copyTexSubImage2D` and doesn't - * require the use of any shaders. Remember the coordinates are given in standard WebGL format, - * where x and y specify the lower-left corner of the section, not the top-left. Also, the - * copy entirely replaces the contents of the target texture, no 'merging' or 'blending' takes - * place. - * @param source The source Render Target. - * @param target The target Render Target. - * @param x The x coordinate of the lower left corner where to start copying. - * @param y The y coordinate of the lower left corner where to start copying. - * @param width The width of the texture. - * @param height The height of the texture. - * @param clear Clear the target before copying? Default true. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - copyFrameRect(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, x: number, y: number, width: number, height: number, clear?: boolean, clearAlpha?: boolean): void; - - /** - * Binds this pipeline and draws the `source` Render Target to the `target` Render Target. - * - * If no `target` is specified, it will pop the framebuffer from the Renderers FBO stack - * and use that instead, which should be done when you need to draw the final results of - * this pipeline to the game canvas. - * - * You can optionally set the shader to be used for the draw here, if this is a multi-shader - * pipeline. By default `currentShader` will be used. If you need to set a shader but not - * a target, just pass `null` as the `target` parameter. - * @param source The Render Target to draw from. - * @param target The Render Target to draw to. If not set, it will pop the fbo from the stack. - * @param clear Clear the target before copying? Only used if `target` parameter is set. Default true. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - * @param currentShader The shader to use during the draw. - */ - bindAndDraw(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, clear?: boolean, clearAlpha?: boolean, currentShader?: Phaser.Renderer.WebGL.WebGLShader): void; - - } - - /** - * The Rope Pipeline is a variation of the Multi Pipeline that uses a `TRIANGLE_STRIP` for - * its topology, instead of TRIANGLES. This is primarily used by the Rope Game Object, - * or anything that extends it. - * - * Prior to Phaser v3.50 this pipeline was called the `TextureTintStripPipeline`. - * - * The fragment shader it uses can be found in `shaders/src/Multi.frag`. - * The vertex shader it uses can be found in `shaders/src/Multi.vert`. - * - * The default shader attributes for this pipeline are: - * - * `inPosition` (vec2, offset 0) - * `inTexCoord` (vec2, offset 8) - * `inTexId` (float, offset 16) - * `inTintEffect` (float, offset 20) - * `inTint` (vec4, offset 24, normalized) - * - * The default shader uniforms for this pipeline are: - * - * `uProjectionMatrix` (mat4) - * `uMainSampler` (sampler2D array) - * - * The pipeline is structurally identical to the Multi Pipeline and should be treated as such. - */ - class RopePipeline extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - - } - - /** - * The Single Pipeline is a special version of the Multi Pipeline that only ever - * uses one texture, bound to texture unit zero. Although not as efficient as the - * Multi Pipeline, it provides an easier way to create custom pipelines that only require - * a single bound texture. - * - * Prior to Phaser v3.50 this pipeline didn't exist, but could be compared to the old `TextureTintPipeline`. - * - * The fragment shader it uses can be found in `shaders/src/Single.frag`. - * The vertex shader it uses can be found in `shaders/src/Single.vert`. - * - * The default shader attributes for this pipeline are: - * - * `inPosition` (vec2, offset 0) - * `inTexCoord` (vec2, offset 8) - * `inTexId` (float, offset 16) - this value is always zero in the Single Pipeline - * `inTintEffect` (float, offset 20) - * `inTint` (vec4, offset 24, normalized) - * - * The default shader uniforms for this pipeline are: - * - * `uProjectionMatrix` (mat4) - * `uMainSampler` (sampler2D) - */ - class SinglePipeline extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - - } - - /** - * The Utility Pipeline is a special-use pipeline that belongs to the Pipeline Manager. - * - * It provides 4 shaders and handy associated methods: - * - * 1) Copy Shader. A fast texture to texture copy shader with optional brightness setting. - * 2) Additive Blend Mode Shader. Blends two textures using an additive blend mode. - * 3) Linear Blend Mode Shader. Blends two textures using a linear blend mode. - * 4) Color Matrix Copy Shader. Draws a texture to a target using a Color Matrix. - * - * You do not extend this pipeline, but instead get a reference to it from the Pipeline - * Manager via the `setUtility` method. You can also access methods such as `copyFrame` - * directly from the Pipeline Manager. - * - * This pipeline provides methods for manipulating framebuffer backed textures, such as - * copying or blending one texture to another, copying a portion of a texture, additively - * blending two textures, flipping textures and more. - * - * The default shader attributes for this pipeline are: - * - * `inPosition` (vec2, offset 0) - * `inTexCoord` (vec2, offset 8) - * - * This pipeline has a hard-coded batch size of 1 and a hard coded set of vertices. - */ - class UtilityPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - - /** - * A default Color Matrix, used by the Color Matrix Shader when one - * isn't provided. - */ - colorMatrix: Phaser.Display.ColorMatrix; - - /** - * A reference to the Copy Shader belonging to this Utility Pipeline. - * - * This property is set during the `boot` method. - */ - copyShader: Phaser.Renderer.WebGL.WebGLShader; - - /** - * A reference to the Additive Blend Shader belonging to this Utility Pipeline. - * - * This property is set during the `boot` method. - */ - addShader: Phaser.Renderer.WebGL.WebGLShader; - - /** - * A reference to the Linear Blend Shader belonging to this Utility Pipeline. - * - * This property is set during the `boot` method. - */ - linearShader: Phaser.Renderer.WebGL.WebGLShader; - - /** - * A reference to the Color Matrix Shader belonging to this Utility Pipeline. - * - * This property is set during the `boot` method. - */ - colorMatrixShader: Phaser.Renderer.WebGL.WebGLShader; - - /** - * A reference to the Full Frame 1 Render Target. - * - * This property is set during the `boot` method. - * - * This Render Target is the full size of the renderer. - * - * You can use this directly in Post FX Pipelines for multi-target effects. - * However, be aware that these targets are shared between all post fx pipelines. - */ - fullFrame1: Phaser.Renderer.WebGL.RenderTarget; - - /** - * A reference to the Full Frame 2 Render Target. - * - * This property is set during the `boot` method. - * - * This Render Target is the full size of the renderer. - * - * You can use this directly in Post FX Pipelines for multi-target effects. - * However, be aware that these targets are shared between all post fx pipelines. - */ - fullFrame2: Phaser.Renderer.WebGL.RenderTarget; - - /** - * A reference to the Half Frame 1 Render Target. - * - * This property is set during the `boot` method. - * - * This Render Target is half the size of the renderer. - * - * You can use this directly in Post FX Pipelines for multi-target effects. - * However, be aware that these targets are shared between all post fx pipelines. - */ - halfFrame1: Phaser.Renderer.WebGL.RenderTarget; - - /** - * A reference to the Half Frame 2 Render Target. - * - * This property is set during the `boot` method. - * - * This Render Target is half the size of the renderer. - * - * You can use this directly in Post FX Pipelines for multi-target effects. - * However, be aware that these targets are shared between all post fx pipelines. - */ - halfFrame2: Phaser.Renderer.WebGL.RenderTarget; - - /** - * Copy the `source` Render Target to the `target` Render Target. - * - * You can optionally set the brightness factor of the copy. - * - * The difference between this method and `drawFrame` is that this method - * uses a faster copy shader, where only the brightness can be modified. - * If you need color level manipulation, see `drawFrame` instead. - * @param source The source Render Target. - * @param target The target Render Target. - * @param brightness The brightness value applied to the frame copy. Default 1. - * @param clear Clear the target before copying? Default true. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - copyFrame(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean): void; - - /** - * Copy the `source` Render Target to the `target` Render Target. - * - * The difference with this copy is that no resizing takes place. If the `source` - * Render Target is larger than the `target` then only a portion the same size as - * the `target` dimensions is copied across. - * - * You can optionally set the brightness factor of the copy. - * @param source The source Render Target. - * @param target The target Render Target. - * @param brightness The brightness value applied to the frame copy. Default 1. - * @param clear Clear the target before copying? Default true. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - * @param eraseMode Erase source from target using ERASE Blend Mode? Default false. - */ - blitFrame(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean): void; - - /** - * Binds the `source` Render Target and then copies a section of it to the `target` Render Target. - * - * This method is extremely fast because it uses `gl.copyTexSubImage2D` and doesn't - * require the use of any shaders. Remember the coordinates are given in standard WebGL format, - * where x and y specify the lower-left corner of the section, not the top-left. Also, the - * copy entirely replaces the contents of the target texture, no 'merging' or 'blending' takes - * place. - * @param source The source Render Target. - * @param target The target Render Target. - * @param x The x coordinate of the lower left corner where to start copying. - * @param y The y coordinate of the lower left corner where to start copying. - * @param width The width of the texture. - * @param height The height of the texture. - * @param clear Clear the target before copying? Default true. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - copyFrameRect(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, x: number, y: number, width: number, height: number, clear?: boolean, clearAlpha?: boolean): void; - - /** - * Pops the framebuffer from the renderers FBO stack and sets that as the active target, - * then draws the `source` Render Target to it. It then resets the renderer textures. - * - * This should be done when you need to draw the _final_ results of a pipeline to the game - * canvas, or the next framebuffer in line on the FBO stack. You should only call this once - * in the `onDraw` handler and it should be the final thing called. Be careful not to call - * this if you need to actually use the pipeline shader, instead of the copy shader. In - * those cases, use the `bindAndDraw` method. - * @param source The Render Target to draw from. - */ - copyToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; - - /** - * Copy the `source` Render Target to the `target` Render Target, using the - * given Color Matrix. - * - * The difference between this method and `copyFrame` is that this method - * uses a color matrix shader, where you have full control over the luminance - * values used during the copy. If you don't need this, you can use the faster - * `copyFrame` method instead. - * @param source The source Render Target. - * @param target The target Render Target. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - * @param colorMatrix The Color Matrix to use when performing the draw. - */ - drawFrame(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean, colorMatrix?: Phaser.Display.ColorMatrix): void; - - /** - * Draws the `source1` and `source2` Render Targets to the `target` Render Target - * using a linear blend effect, which is controlled by the `strength` parameter. - * @param source1 The first source Render Target. - * @param source2 The second source Render Target. - * @param target The target Render Target. - * @param strength The strength of the blend. Default 1. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - * @param blendShader The shader to use during the blend copy. - */ - blendFrames(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean, blendShader?: Phaser.Renderer.WebGL.WebGLShader): void; - - /** - * Draws the `source1` and `source2` Render Targets to the `target` Render Target - * using an additive blend effect, which is controlled by the `strength` parameter. - * @param source1 The first source Render Target. - * @param source2 The second source Render Target. - * @param target The target Render Target. - * @param strength The strength of the blend. Default 1. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - blendFramesAdditive(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): void; - - /** - * Clears the given Render Target. - * @param target The Render Target to clear. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - clearFrame(target: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean): void; - - /** - * Set the UV values for the 6 vertices that make up the quad used by the shaders - * in the Utility Pipeline. - * - * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. - * @param uA The u value of vertex A. - * @param vA The v value of vertex A. - * @param uB The u value of vertex B. - * @param vB The v value of vertex B. - * @param uC The u value of vertex C. - * @param vC The v value of vertex C. - * @param uD The u value of vertex D. - * @param vD The v value of vertex D. - */ - setUVs(uA: number, vA: number, uB: number, vB: number, uC: number, vC: number, uD: number, vD: number): void; - - /** - * Sets the vertex UV coordinates of the quad used by the shaders in the Utility Pipeline - * so that they correctly adjust the texture coordinates for a blit frame effect. - * - * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. - * @param source The source Render Target. - * @param target The target Render Target. - */ - setTargetUVs(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget): void; - - /** - * Horizontally flips the UV coordinates of the quad used by the shaders in this - * Utility Pipeline. - * - * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. - */ - flipX(): void; - - /** - * Vertically flips the UV coordinates of the quad used by the shaders in this - * Utility Pipeline. - * - * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. - */ - flipY(): void; - - /** - * Resets the quad vertice UV values to their default settings. - * - * The quad is used by all shaders of the Utility Pipeline. - */ - resetUVs(): void; - - } - - } - /** * A Render Target encapsulates a WebGL framebuffer and the WebGL Texture that displays it. * @@ -83853,205 +82639,1256 @@ declare namespace Phaser { } + /** + * 8-bit twos complement signed integer. + */ + var BYTE: Phaser.Types.Renderer.WebGL.WebGLConst; + + /** + * 8-bit twos complement unsigned integer. + */ + var UNSIGNED_BYTE: Phaser.Types.Renderer.WebGL.WebGLConst; + + /** + * 16-bit twos complement signed integer. + */ + var SHORT: Phaser.Types.Renderer.WebGL.WebGLConst; + + /** + * 16-bit twos complement unsigned integer. + */ + var UNSIGNED_SHORT: Phaser.Types.Renderer.WebGL.WebGLConst; + + /** + * 32-bit twos complement signed integer. + */ + var INT: Phaser.Types.Renderer.WebGL.WebGLConst; + + /** + * 32-bit twos complement unsigned integer. + */ + var UNSIGNED_INT: Phaser.Types.Renderer.WebGL.WebGLConst; + + /** + * 32-bit IEEE floating point number. + */ + var FLOAT: Phaser.Types.Renderer.WebGL.WebGLConst; + + namespace Pipelines { + /** + * The Bitmap Mask Pipeline handles all of the bitmap mask rendering in WebGL for applying + * alpha masks to Game Objects. It works by sampling two texture on the fragment shader and + * using the fragments alpha to clip the region. + * + * The fragment shader it uses can be found in `shaders/src/BitmapMask.frag`. + * The vertex shader it uses can be found in `shaders/src/BitmapMask.vert`. + * + * The default shader attributes for this pipeline are: + * + * `inPosition` (vec2, offset 0) + * + * The default shader uniforms for this pipeline are: + * + * `uResolution` (vec2) + * `uMainSampler` (sampler2D) + * `uMaskSampler` (sampler2D) + * `uInvertMaskAlpha` (bool) + */ + class BitmapMaskPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + + /** + * Binds necessary resources and renders the mask to a separated framebuffer. + * The framebuffer for the masked object is also bound for further use. + * @param mask GameObject used as mask. + * @param maskedObject GameObject masked by the mask GameObject. + * @param camera The camera rendering the current mask. + */ + beginMask(mask: Phaser.GameObjects.GameObject, maskedObject: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; + + /** + * The masked game objects framebuffer is unbound and its texture + * is bound together with the mask texture and the mask shader and + * a draw call with a single quad is processed. Here is where the + * masking effect is applied. + * @param mask GameObject used as a mask. + */ + endMask(mask: Phaser.GameObjects.GameObject): void; + + } + + /** + * The Graphics Pipeline is the rendering pipeline used by Phaser in WebGL when drawing + * primitive geometry objects, such as the Graphics Game Object, or the Shape Game Objects + * such as Arc, Line, Rectangle and Star. It handles the preperation and batching of related vertices. + * + * Prior to Phaser v3.50 the functions of this pipeline were merged with the `TextureTintPipeline`. + * + * The fragment shader it uses can be found in `shaders/src/Graphics.frag`. + * The vertex shader it uses can be found in `shaders/src/Graphics.vert`. + * + * The default shader attributes for this pipeline are: + * + * `inPosition` (vec2) + * `inColor` (vec4, normalized) + * + * The default shader uniforms for this pipeline are: + * + * `uProjectionMatrix` (mat4) + */ + class GraphicsPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + + /** + * A temporary Transform Matrix, re-used internally during batching by the + * Shape Game Objects. + */ + calcMatrix: Phaser.GameObjects.Components.TransformMatrix; + + /** + * Pushes a filled rectangle into the vertex batch. + * + * Rectangle factors in the given transform matrices before adding to the batch. + * @param x Horizontal top left coordinate of the rectangle. + * @param y Vertical top left coordinate of the rectangle. + * @param width Width of the rectangle. + * @param height Height of the rectangle. + * @param currentMatrix The current transform. + * @param parentMatrix The parent transform. + */ + batchFillRect(x: number, y: number, width: number, height: number, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Pushes a filled triangle into the vertex batch. + * + * Triangle factors in the given transform matrices before adding to the batch. + * @param x0 Point 0 x coordinate. + * @param y0 Point 0 y coordinate. + * @param x1 Point 1 x coordinate. + * @param y1 Point 1 y coordinate. + * @param x2 Point 2 x coordinate. + * @param y2 Point 2 y coordinate. + * @param currentMatrix The current transform. + * @param parentMatrix The parent transform. + */ + batchFillTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Pushes a stroked triangle into the vertex batch. + * + * Triangle factors in the given transform matrices before adding to the batch. + * + * The triangle is created from 3 lines and drawn using the `batchStrokePath` method. + * @param x0 Point 0 x coordinate. + * @param y0 Point 0 y coordinate. + * @param x1 Point 1 x coordinate. + * @param y1 Point 1 y coordinate. + * @param x2 Point 2 x coordinate. + * @param y2 Point 2 y coordinate. + * @param lineWidth The width of the line in pixels. + * @param currentMatrix The current transform. + * @param parentMatrix The parent transform. + */ + batchStrokeTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, lineWidth: number, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Adds the given path to the vertex batch for rendering. + * + * It works by taking the array of path data and then passing it through Earcut, which + * creates a list of polygons. Each polygon is then added to the batch. + * + * The path is always automatically closed because it's filled. + * @param path Collection of points that represent the path. + * @param currentMatrix The current transform. + * @param parentMatrix The parent transform. + */ + batchFillPath(path: Phaser.Types.Math.Vector2Like[], currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Adds the given path to the vertex batch for rendering. + * + * It works by taking the array of path data and calling `batchLine` for each section + * of the path. + * + * The path is optionally closed at the end. + * @param path Collection of points that represent the path. + * @param lineWidth The width of the line segments in pixels. + * @param pathOpen Indicates if the path should be closed or left open. + * @param currentMatrix The current transform. + * @param parentMatrix The parent transform. + */ + batchStrokePath(path: Phaser.Types.Math.Vector2Like[], lineWidth: number, pathOpen: boolean, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Creates a line out of 4 quads and adds it to the vertex batch based on the given line values. + * @param ax x coordinate of the start of the line. + * @param ay y coordinate of the start of the line. + * @param bx x coordinate of the end of the line. + * @param by y coordinate of the end of the line. + * @param aLineWidth Width of the start of the line. + * @param bLineWidth Width of the end of the line. + * @param index If this line is part of a multi-line draw, the index of the line in the draw. + * @param closePath Does this line close a multi-line path? + * @param currentMatrix The current transform. + * @param parentMatrix The parent transform. + */ + batchLine(ax: number, ay: number, bx: number, by: number, aLineWidth: number, bLineWidth: number, index: number, closePath: boolean, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Adds a single vertex to the current vertex buffer and increments the + * `vertexCount` property by 1. + * + * This method is called directly by `batchTri` and `batchQuad`. + * + * It does not perform any batch limit checking itself, so if you need to call + * this method directly, do so in the same way that `batchQuad` does, for example. + * @param x The vertex x position. + * @param y The vertex y position. + * @param tint The tint color value. + */ + batchVert(x: number, y: number, tint: number): void; + + /** + * Destroys all shader instances, removes all object references and nulls all external references. + */ + destroy(): this; + + } + + /** + * The Light Pipeline is an extension of the Multi Pipeline and uses a custom shader + * designed to handle forward diffused rendering of 2D lights in a Scene. + * + * The shader works in tandem with Light Game Objects, and optionally texture normal maps, + * to provide an ambient illumination effect. + * + * If you wish to provide your own shader, you can use the `%LIGHT_COUNT%` declaration in the source, + * and it will be automatically replaced at run-time with the total number of configured lights. + * + * The maximum number of lights can be set in the Render Config `maxLights` property and defaults to 10. + * + * Prior to Phaser v3.50 this pipeline was called the `ForwardDiffuseLightPipeline`. + * + * The fragment shader it uses can be found in `shaders/src/Light.frag`. + * The vertex shader it uses can be found in `shaders/src/Multi.vert`. + * + * The default shader attributes for this pipeline are: + * + * `inPosition` (vec2, offset 0) + * `inTexCoord` (vec2, offset 8) + * `inTexId` (float, offset 16) + * `inTintEffect` (float, offset 20) + * `inTint` (vec4, offset 24, normalized) + * + * The default shader uniforms for this pipeline are those from the Multi Pipeline, plus: + * + * `uMainSampler` (sampler2D) + * `uNormSampler` (sampler2D) + * `uCamera` (vec4) + * `uResolution` (vec2) + * `uAmbientLightColor` (vec3) + * `uInverseRotationMatrix` (mat3) + * `uLights` (Light struct) + */ + class LightPipeline extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + + /** + * Stores a default normal map, which is an object with a `glTexture` property that + * maps to a 1x1 texture of the color #7f7fff created in the `boot` method. + */ + defaultNormalMap: object; + + /** + * A boolean that is set automatically during `onRender` that determines + * if the Scene LightManager is active, or not. + */ + readonly lightsActive: boolean; + + /** + * Called when the Game has fully booted and the Renderer has finished setting up. + * + * By this stage all Game level systems are now in place and you can perform any final + * tasks that the pipeline may need that relied on game systems such as the Texture Manager. + */ + boot(): void; + + /** + * Rotates the normal map vectors inversely by the given angle. + * Only works in 2D space. + * @param rotation The angle of rotation in radians. + */ + setNormalMapRotation(rotation: number): void; + + /** + * Returns the normal map WebGLTexture from the given Game Object. + * If the Game Object doesn't have one, it returns the default normal map from this pipeline instead. + * @param gameObject The Game Object to get the normal map from. + */ + getNormalMap(gameObject?: Phaser.GameObjects.GameObject): WebGLTexture; + + /** + * Takes a Sprite Game Object, or any object that extends it, and adds it to the batch. + * @param gameObject The texture based Game Object to add to the batch. + * @param camera The Camera to use for the rendering transform. + * @param parentTransformMatrix The transform matrix of the parent container, if set. + */ + batchSprite(gameObject: Phaser.GameObjects.Image | Phaser.GameObjects.Sprite, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Generic function for batching a textured quad using argument values instead of a Game Object. + * @param gameObject Source GameObject. + * @param texture Raw WebGLTexture associated with the quad. + * @param textureWidth Real texture width. + * @param textureHeight Real texture height. + * @param srcX X coordinate of the quad. + * @param srcY Y coordinate of the quad. + * @param srcWidth Width of the quad. + * @param srcHeight Height of the quad. + * @param scaleX X component of scale. + * @param scaleY Y component of scale. + * @param rotation Rotation of the quad. + * @param flipX Indicates if the quad is horizontally flipped. + * @param flipY Indicates if the quad is vertically flipped. + * @param scrollFactorX By which factor is the quad affected by the camera horizontal scroll. + * @param scrollFactorY By which factor is the quad effected by the camera vertical scroll. + * @param displayOriginX Horizontal origin in pixels. + * @param displayOriginY Vertical origin in pixels. + * @param frameX X coordinate of the texture frame. + * @param frameY Y coordinate of the texture frame. + * @param frameWidth Width of the texture frame. + * @param frameHeight Height of the texture frame. + * @param tintTL Tint for top left. + * @param tintTR Tint for top right. + * @param tintBL Tint for bottom left. + * @param tintBR Tint for bottom right. + * @param tintEffect The tint effect. + * @param uOffset Horizontal offset on texture coordinate. + * @param vOffset Vertical offset on texture coordinate. + * @param camera Current used camera. + * @param parentTransformMatrix Parent container. + * @param skipFlip Skip the renderTexture check. Default false. + * @param textureUnit Use the currently bound texture unit? + */ + batchTexture(gameObject: Phaser.GameObjects.GameObject, texture: WebGLTexture, textureWidth: number, textureHeight: number, srcX: number, srcY: number, srcWidth: number, srcHeight: number, scaleX: number, scaleY: number, rotation: number, flipX: boolean, flipY: boolean, scrollFactorX: number, scrollFactorY: number, displayOriginX: number, displayOriginY: number, frameX: number, frameY: number, frameWidth: number, frameHeight: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number, uOffset: number, vOffset: number, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix, skipFlip?: boolean, textureUnit?: number): void; + + /** + * Adds a Texture Frame into the batch for rendering. + * @param frame The Texture Frame to be rendered. + * @param x The horizontal position to render the texture at. + * @param y The vertical position to render the texture at. + * @param tint The tint color. + * @param alpha The alpha value. + * @param transformMatrix The Transform Matrix to use for the texture. + * @param parentTransformMatrix A parent Transform Matrix. + */ + batchTextureFrame(frame: Phaser.Textures.Frame, x: number, y: number, tint: number, alpha: number, transformMatrix: Phaser.GameObjects.Components.TransformMatrix, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; + + } + + /** + * The Multi Pipeline is the core 2D texture rendering pipeline used by Phaser in WebGL. + * Virtually all Game Objects use this pipeline by default, including Sprites, Graphics + * and Tilemaps. It handles the batching of quads and tris, as well as methods for + * drawing and batching geometry data. + * + * Prior to Phaser v3.50 this pipeline was called the `TextureTintPipeline`. + * + * In previous versions of Phaser only one single texture unit was supported at any one time. + * The Multi Pipeline is an evolution of the old Texture Tint Pipeline, updated to support + * multi-textures for increased performance. + * + * The fragment shader it uses can be found in `shaders/src/Multi.frag`. + * The vertex shader it uses can be found in `shaders/src/Multi.vert`. + * + * The default shader attributes for this pipeline are: + * + * `inPosition` (vec2, offset 0) + * `inTexCoord` (vec2, offset 8) + * `inTexId` (float, offset 16) + * `inTintEffect` (float, offset 20) + * `inTint` (vec4, offset 24, normalized) + * + * The default shader uniforms for this pipeline are: + * + * `uProjectionMatrix` (mat4) + * `uMainSampler` (sampler2D array) + * + * If you wish to create a custom pipeline extending from this one, you can use two string + * declarations in your fragment shader source: `%count%` and `%forloop%`, where `count` is + * used to set the number of `sampler2Ds` available, and `forloop` is a block of GLSL code + * that will get the currently bound texture unit. + * + * This pipeline will automatically inject that code for you, should those values exist + * in your shader source. If you wish to handle this yourself, you can also use the + * function `Utils.parseFragmentShaderMaxTextures`. + * + * If you wish to create a pipeline that works from a single texture, or that doesn't have + * internal texture iteration, please see the `SinglePipeline` instead. + */ + class MultiPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + + /** + * Called every time the pipeline is bound by the renderer. + * Sets the shader program, vertex buffer and other resources. + * Should only be called when changing pipeline. + */ + bind(): this; + + /** + * Takes a Sprite Game Object, or any object that extends it, and adds it to the batch. + * @param gameObject The texture based Game Object to add to the batch. + * @param camera The Camera to use for the rendering transform. + * @param parentTransformMatrix The transform matrix of the parent container, if set. + */ + batchSprite(gameObject: Phaser.GameObjects.Image | Phaser.GameObjects.Sprite, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Generic function for batching a textured quad using argument values instead of a Game Object. + * @param gameObject Source GameObject. + * @param texture Raw WebGLTexture associated with the quad. + * @param textureWidth Real texture width. + * @param textureHeight Real texture height. + * @param srcX X coordinate of the quad. + * @param srcY Y coordinate of the quad. + * @param srcWidth Width of the quad. + * @param srcHeight Height of the quad. + * @param scaleX X component of scale. + * @param scaleY Y component of scale. + * @param rotation Rotation of the quad. + * @param flipX Indicates if the quad is horizontally flipped. + * @param flipY Indicates if the quad is vertically flipped. + * @param scrollFactorX By which factor is the quad affected by the camera horizontal scroll. + * @param scrollFactorY By which factor is the quad effected by the camera vertical scroll. + * @param displayOriginX Horizontal origin in pixels. + * @param displayOriginY Vertical origin in pixels. + * @param frameX X coordinate of the texture frame. + * @param frameY Y coordinate of the texture frame. + * @param frameWidth Width of the texture frame. + * @param frameHeight Height of the texture frame. + * @param tintTL Tint for top left. + * @param tintTR Tint for top right. + * @param tintBL Tint for bottom left. + * @param tintBR Tint for bottom right. + * @param tintEffect The tint effect. + * @param uOffset Horizontal offset on texture coordinate. + * @param vOffset Vertical offset on texture coordinate. + * @param camera Current used camera. + * @param parentTransformMatrix Parent container. + * @param skipFlip Skip the renderTexture check. Default false. + * @param textureUnit Use the currently bound texture unit? + */ + batchTexture(gameObject: Phaser.GameObjects.GameObject, texture: WebGLTexture, textureWidth: number, textureHeight: number, srcX: number, srcY: number, srcWidth: number, srcHeight: number, scaleX: number, scaleY: number, rotation: number, flipX: boolean, flipY: boolean, scrollFactorX: number, scrollFactorY: number, displayOriginX: number, displayOriginY: number, frameX: number, frameY: number, frameWidth: number, frameHeight: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number, uOffset: number, vOffset: number, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix, skipFlip?: boolean, textureUnit?: number): void; + + /** + * Adds a Texture Frame into the batch for rendering. + * @param frame The Texture Frame to be rendered. + * @param x The horizontal position to render the texture at. + * @param y The vertical position to render the texture at. + * @param tint The tint color. + * @param alpha The alpha value. + * @param transformMatrix The Transform Matrix to use for the texture. + * @param parentTransformMatrix A parent Transform Matrix. + */ + batchTextureFrame(frame: Phaser.Textures.Frame, x: number, y: number, tint: number, alpha: number, transformMatrix: Phaser.GameObjects.Components.TransformMatrix, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; + + } + + /** + * The Point Light Pipeline handles rendering the Point Light Game Objects in WebGL. + * + * The fragment shader it uses can be found in `shaders/src/PointLight.frag`. + * The vertex shader it uses can be found in `shaders/src/PointLight.vert`. + * + * The default shader attributes for this pipeline are: + * + * `inPosition` (vec2) + * `inLightPosition` (vec2) + * `inLightRadius` (float) + * `inLightAttenuation` (float) + * `inLightColor` (vec4) + * + * The default shader uniforms for this pipeline are: + * + * `uProjectionMatrix` (mat4) + * `uResolution` (vec2) + * `uCameraZoom` (sampler2D) + */ + class PointLightPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + + /** + * Adds a Point Light Game Object to the batch, flushing if required. + * @param light The Point Light Game Object. + * @param camera The camera rendering the Point Light. + * @param x0 The top-left x position. + * @param y0 The top-left y position. + * @param x1 The bottom-left x position. + * @param y1 The bottom-left y position. + * @param x2 The bottom-right x position. + * @param y2 The bottom-right y position. + * @param x3 The top-right x position. + * @param y3 The top-right y position. + * @param lightX The horizontal center of the light. + * @param lightY The vertical center of the light. + */ + batchPointLight(light: Phaser.GameObjects.PointLight, camera: Phaser.Cameras.Scene2D.Camera, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, lightX: number, lightY: number): void; + + /** + * Adds a single Point Light vertex to the current vertex buffer and increments the + * `vertexCount` property by 1. + * + * This method is called directly by `batchPointLight`. + * @param x The vertex x position. + * @param y The vertex y position. + * @param lightX The horizontal center of the light. + * @param lightY The vertical center of the light. + * @param radius The radius of the light. + * @param attenuation The attenuation of the light. + * @param r The red color channel of the light. + * @param g The green color channel of the light. + * @param b The blue color channel of the light. + * @param a The alpha color channel of the light. + */ + batchLightVert(x: number, y: number, lightX: number, lightY: number, radius: number, attenuation: number, r: number, g: number, b: number, a: number): void; + + } + + /** + * The Post FX Pipeline is a special kind of pipeline specifically for handling post + * processing effects. Where-as a standard Pipeline allows you to control the process + * of rendering Game Objects by configuring the shaders and attributes used to draw them, + * a Post FX Pipeline is designed to allow you to apply processing _after_ the Game Object/s + * have been rendered. Typical examples of post processing effects are bloom filters, + * blurs, light effects and color manipulation. + * + * The pipeline works by creating a tiny vertex buffer with just one single hard-coded quad + * in it. Game Objects can have a Post Pipeline set on them. Those objects are then rendered + * using their standard pipeline, but are redirected to the Render Targets owned by the + * post pipeline, which can then apply their own shaders and effects, before passing them + * back to the main renderer. + * + * Please see the Phaser 3 examples for further details on this extensive subject. + * + * The default fragment shader it uses can be found in `shaders/src/PostFX.frag`. + * The default vertex shader it uses can be found in `shaders/src/Quad.vert`. + * + * The default shader attributes for this pipeline are: + * + * `inPosition` (vec2, offset 0) + * `inTexCoord` (vec2, offset 8) + * + * The vertices array layout is: + * + * -1, 1 B----C 1, 1 + * 0, 1 | /| 1, 1 + * | / | + * | / | + * |/ | + * -1, -1 A----D 1, -1 + * 0, 0 1, 0 + * + * A = -1, -1 (pos) and 0, 0 (uv) + * B = -1, 1 (pos) and 0, 1 (uv) + * C = 1, 1 (pos) and 1, 1 (uv) + * D = 1, -1 (pos) and 1, 0 (uv) + * + * First tri: A, B, C + * Second tri: A, C, D + * + * Array index: + * + * 0 = Tri 1 - Vert A - x pos + * 1 = Tri 1 - Vert A - y pos + * 2 = Tri 1 - Vert A - uv u + * 3 = Tri 1 - Vert A - uv v + * + * 4 = Tri 1 - Vert B - x pos + * 5 = Tri 1 - Vert B - y pos + * 6 = Tri 1 - Vert B - uv u + * 7 = Tri 1 - Vert B - uv v + * + * 8 = Tri 1 - Vert C - x pos + * 9 = Tri 1 - Vert C - y pos + * 10 = Tri 1 - Vert C - uv u + * 11 = Tri 1 - Vert C - uv v + * + * 12 = Tri 2 - Vert A - x pos + * 13 = Tri 2 - Vert A - y pos + * 14 = Tri 2 - Vert A - uv u + * 15 = Tri 2 - Vert A - uv v + * + * 16 = Tri 2 - Vert C - x pos + * 17 = Tri 2 - Vert C - y pos + * 18 = Tri 2 - Vert C - uv u + * 19 = Tri 2 - Vert C - uv v + * + * 20 = Tri 2 - Vert D - x pos + * 21 = Tri 2 - Vert D - y pos + * 22 = Tri 2 - Vert D - uv u + * 23 = Tri 2 - Vert D - uv v + */ + class PostFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + + /** + * If this post-pipeline belongs to a Game Object or Camera, this contains a reference to it. + */ + gameObject: Phaser.GameObjects.GameObject; + + /** + * A Color Matrix instance belonging to this pipeline. + * + * Used during calls to the `drawFrame` method. + */ + colorMatrix: Phaser.Display.ColorMatrix; + + /** + * A reference to the Full Frame 1 Render Target that belongs to the + * Utility Pipeline. This property is set during the `boot` method. + * + * This Render Target is the full size of the renderer. + * + * You can use this directly in Post FX Pipelines for multi-target effects. + * However, be aware that these targets are shared between all post fx pipelines. + */ + fullFrame1: Phaser.Renderer.WebGL.RenderTarget; + + /** + * A reference to the Full Frame 2 Render Target that belongs to the + * Utility Pipeline. This property is set during the `boot` method. + * + * This Render Target is the full size of the renderer. + * + * You can use this directly in Post FX Pipelines for multi-target effects. + * However, be aware that these targets are shared between all post fx pipelines. + */ + fullFrame2: Phaser.Renderer.WebGL.RenderTarget; + + /** + * A reference to the Half Frame 1 Render Target that belongs to the + * Utility Pipeline. This property is set during the `boot` method. + * + * This Render Target is half the size of the renderer. + * + * You can use this directly in Post FX Pipelines for multi-target effects. + * However, be aware that these targets are shared between all post fx pipelines. + */ + halfFrame1: Phaser.Renderer.WebGL.RenderTarget; + + /** + * A reference to the Half Frame 2 Render Target that belongs to the + * Utility Pipeline. This property is set during the `boot` method. + * + * This Render Target is half the size of the renderer. + * + * You can use this directly in Post FX Pipelines for multi-target effects. + * However, be aware that these targets are shared between all post fx pipelines. + */ + halfFrame2: Phaser.Renderer.WebGL.RenderTarget; + + /** + * Copy the `source` Render Target to the `target` Render Target. + * + * You can optionally set the brightness factor of the copy. + * + * The difference between this method and `drawFrame` is that this method + * uses a faster copy shader, where only the brightness can be modified. + * If you need color level manipulation, see `drawFrame` instead. + * @param source The source Render Target. + * @param target The target Render Target. + * @param brightness The brightness value applied to the frame copy. Default 1. + * @param clear Clear the target before copying? Default true. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + copyFrame(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean): void; + + /** + * Pops the framebuffer from the renderers FBO stack and sets that as the active target, + * then draws the `source` Render Target to it. It then resets the renderer textures. + * + * This should be done when you need to draw the _final_ results of a pipeline to the game + * canvas, or the next framebuffer in line on the FBO stack. You should only call this once + * in the `onDraw` handler and it should be the final thing called. Be careful not to call + * this if you need to actually use the pipeline shader, instead of the copy shader. In + * those cases, use the `bindAndDraw` method. + * @param source The Render Target to draw from. + */ + copyToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; + + /** + * Copy the `source` Render Target to the `target` Render Target, using the + * given Color Matrix. + * + * The difference between this method and `copyFrame` is that this method + * uses a color matrix shader, where you have full control over the luminance + * values used during the copy. If you don't need this, you can use the faster + * `copyFrame` method instead. + * @param source The source Render Target. + * @param target The target Render Target. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + drawFrame(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean): void; + + /** + * Draws the `source1` and `source2` Render Targets to the `target` Render Target + * using a linear blend effect, which is controlled by the `strength` parameter. + * @param source1 The first source Render Target. + * @param source2 The second source Render Target. + * @param target The target Render Target. + * @param strength The strength of the blend. Default 1. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + blendFrames(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): void; + + /** + * Draws the `source1` and `source2` Render Targets to the `target` Render Target + * using an additive blend effect, which is controlled by the `strength` parameter. + * @param source1 The first source Render Target. + * @param source2 The second source Render Target. + * @param target The target Render Target. + * @param strength The strength of the blend. Default 1. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + blendFramesAdditive(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): void; + + /** + * Clears the given Render Target. + * @param target The Render Target to clear. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + clearFrame(target: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean): void; + + /** + * Copy the `source` Render Target to the `target` Render Target. + * + * The difference with this copy is that no resizing takes place. If the `source` + * Render Target is larger than the `target` then only a portion the same size as + * the `target` dimensions is copied across. + * + * You can optionally set the brightness factor of the copy. + * @param source The source Render Target. + * @param target The target Render Target. + * @param brightness The brightness value applied to the frame copy. Default 1. + * @param clear Clear the target before copying? Default true. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + * @param eraseMode Erase source from target using ERASE Blend Mode? Default false. + */ + blitFrame(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean): void; + + /** + * Binds the `source` Render Target and then copies a section of it to the `target` Render Target. + * + * This method is extremely fast because it uses `gl.copyTexSubImage2D` and doesn't + * require the use of any shaders. Remember the coordinates are given in standard WebGL format, + * where x and y specify the lower-left corner of the section, not the top-left. Also, the + * copy entirely replaces the contents of the target texture, no 'merging' or 'blending' takes + * place. + * @param source The source Render Target. + * @param target The target Render Target. + * @param x The x coordinate of the lower left corner where to start copying. + * @param y The y coordinate of the lower left corner where to start copying. + * @param width The width of the texture. + * @param height The height of the texture. + * @param clear Clear the target before copying? Default true. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + copyFrameRect(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, x: number, y: number, width: number, height: number, clear?: boolean, clearAlpha?: boolean): void; + + /** + * Binds this pipeline and draws the `source` Render Target to the `target` Render Target. + * + * If no `target` is specified, it will pop the framebuffer from the Renderers FBO stack + * and use that instead, which should be done when you need to draw the final results of + * this pipeline to the game canvas. + * + * You can optionally set the shader to be used for the draw here, if this is a multi-shader + * pipeline. By default `currentShader` will be used. If you need to set a shader but not + * a target, just pass `null` as the `target` parameter. + * @param source The Render Target to draw from. + * @param target The Render Target to draw to. If not set, it will pop the fbo from the stack. + * @param clear Clear the target before copying? Only used if `target` parameter is set. Default true. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + * @param currentShader The shader to use during the draw. + */ + bindAndDraw(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, clear?: boolean, clearAlpha?: boolean, currentShader?: Phaser.Renderer.WebGL.WebGLShader): void; + + } + + /** + * The Rope Pipeline is a variation of the Multi Pipeline that uses a `TRIANGLE_STRIP` for + * its topology, instead of TRIANGLES. This is primarily used by the Rope Game Object, + * or anything that extends it. + * + * Prior to Phaser v3.50 this pipeline was called the `TextureTintStripPipeline`. + * + * The fragment shader it uses can be found in `shaders/src/Multi.frag`. + * The vertex shader it uses can be found in `shaders/src/Multi.vert`. + * + * The default shader attributes for this pipeline are: + * + * `inPosition` (vec2, offset 0) + * `inTexCoord` (vec2, offset 8) + * `inTexId` (float, offset 16) + * `inTintEffect` (float, offset 20) + * `inTint` (vec4, offset 24, normalized) + * + * The default shader uniforms for this pipeline are: + * + * `uProjectionMatrix` (mat4) + * `uMainSampler` (sampler2D array) + * + * The pipeline is structurally identical to the Multi Pipeline and should be treated as such. + */ + class RopePipeline extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + + } + + /** + * The Single Pipeline is a special version of the Multi Pipeline that only ever + * uses one texture, bound to texture unit zero. Although not as efficient as the + * Multi Pipeline, it provides an easier way to create custom pipelines that only require + * a single bound texture. + * + * Prior to Phaser v3.50 this pipeline didn't exist, but could be compared to the old `TextureTintPipeline`. + * + * The fragment shader it uses can be found in `shaders/src/Single.frag`. + * The vertex shader it uses can be found in `shaders/src/Single.vert`. + * + * The default shader attributes for this pipeline are: + * + * `inPosition` (vec2, offset 0) + * `inTexCoord` (vec2, offset 8) + * `inTexId` (float, offset 16) - this value is always zero in the Single Pipeline + * `inTintEffect` (float, offset 20) + * `inTint` (vec4, offset 24, normalized) + * + * The default shader uniforms for this pipeline are: + * + * `uProjectionMatrix` (mat4) + * `uMainSampler` (sampler2D) + */ + class SinglePipeline extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + + } + + /** + * The Utility Pipeline is a special-use pipeline that belongs to the Pipeline Manager. + * + * It provides 4 shaders and handy associated methods: + * + * 1) Copy Shader. A fast texture to texture copy shader with optional brightness setting. + * 2) Additive Blend Mode Shader. Blends two textures using an additive blend mode. + * 3) Linear Blend Mode Shader. Blends two textures using a linear blend mode. + * 4) Color Matrix Copy Shader. Draws a texture to a target using a Color Matrix. + * + * You do not extend this pipeline, but instead get a reference to it from the Pipeline + * Manager via the `setUtility` method. You can also access methods such as `copyFrame` + * directly from the Pipeline Manager. + * + * This pipeline provides methods for manipulating framebuffer backed textures, such as + * copying or blending one texture to another, copying a portion of a texture, additively + * blending two textures, flipping textures and more. + * + * The default shader attributes for this pipeline are: + * + * `inPosition` (vec2, offset 0) + * `inTexCoord` (vec2, offset 8) + * + * This pipeline has a hard-coded batch size of 1 and a hard coded set of vertices. + */ + class UtilityPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + + /** + * A default Color Matrix, used by the Color Matrix Shader when one + * isn't provided. + */ + colorMatrix: Phaser.Display.ColorMatrix; + + /** + * A reference to the Copy Shader belonging to this Utility Pipeline. + * + * This property is set during the `boot` method. + */ + copyShader: Phaser.Renderer.WebGL.WebGLShader; + + /** + * A reference to the Additive Blend Shader belonging to this Utility Pipeline. + * + * This property is set during the `boot` method. + */ + addShader: Phaser.Renderer.WebGL.WebGLShader; + + /** + * A reference to the Linear Blend Shader belonging to this Utility Pipeline. + * + * This property is set during the `boot` method. + */ + linearShader: Phaser.Renderer.WebGL.WebGLShader; + + /** + * A reference to the Color Matrix Shader belonging to this Utility Pipeline. + * + * This property is set during the `boot` method. + */ + colorMatrixShader: Phaser.Renderer.WebGL.WebGLShader; + + /** + * A reference to the Full Frame 1 Render Target. + * + * This property is set during the `boot` method. + * + * This Render Target is the full size of the renderer. + * + * You can use this directly in Post FX Pipelines for multi-target effects. + * However, be aware that these targets are shared between all post fx pipelines. + */ + fullFrame1: Phaser.Renderer.WebGL.RenderTarget; + + /** + * A reference to the Full Frame 2 Render Target. + * + * This property is set during the `boot` method. + * + * This Render Target is the full size of the renderer. + * + * You can use this directly in Post FX Pipelines for multi-target effects. + * However, be aware that these targets are shared between all post fx pipelines. + */ + fullFrame2: Phaser.Renderer.WebGL.RenderTarget; + + /** + * A reference to the Half Frame 1 Render Target. + * + * This property is set during the `boot` method. + * + * This Render Target is half the size of the renderer. + * + * You can use this directly in Post FX Pipelines for multi-target effects. + * However, be aware that these targets are shared between all post fx pipelines. + */ + halfFrame1: Phaser.Renderer.WebGL.RenderTarget; + + /** + * A reference to the Half Frame 2 Render Target. + * + * This property is set during the `boot` method. + * + * This Render Target is half the size of the renderer. + * + * You can use this directly in Post FX Pipelines for multi-target effects. + * However, be aware that these targets are shared between all post fx pipelines. + */ + halfFrame2: Phaser.Renderer.WebGL.RenderTarget; + + /** + * Copy the `source` Render Target to the `target` Render Target. + * + * You can optionally set the brightness factor of the copy. + * + * The difference between this method and `drawFrame` is that this method + * uses a faster copy shader, where only the brightness can be modified. + * If you need color level manipulation, see `drawFrame` instead. + * @param source The source Render Target. + * @param target The target Render Target. + * @param brightness The brightness value applied to the frame copy. Default 1. + * @param clear Clear the target before copying? Default true. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + copyFrame(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean): void; + + /** + * Copy the `source` Render Target to the `target` Render Target. + * + * The difference with this copy is that no resizing takes place. If the `source` + * Render Target is larger than the `target` then only a portion the same size as + * the `target` dimensions is copied across. + * + * You can optionally set the brightness factor of the copy. + * @param source The source Render Target. + * @param target The target Render Target. + * @param brightness The brightness value applied to the frame copy. Default 1. + * @param clear Clear the target before copying? Default true. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + * @param eraseMode Erase source from target using ERASE Blend Mode? Default false. + */ + blitFrame(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean): void; + + /** + * Binds the `source` Render Target and then copies a section of it to the `target` Render Target. + * + * This method is extremely fast because it uses `gl.copyTexSubImage2D` and doesn't + * require the use of any shaders. Remember the coordinates are given in standard WebGL format, + * where x and y specify the lower-left corner of the section, not the top-left. Also, the + * copy entirely replaces the contents of the target texture, no 'merging' or 'blending' takes + * place. + * @param source The source Render Target. + * @param target The target Render Target. + * @param x The x coordinate of the lower left corner where to start copying. + * @param y The y coordinate of the lower left corner where to start copying. + * @param width The width of the texture. + * @param height The height of the texture. + * @param clear Clear the target before copying? Default true. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + copyFrameRect(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, x: number, y: number, width: number, height: number, clear?: boolean, clearAlpha?: boolean): void; + + /** + * Pops the framebuffer from the renderers FBO stack and sets that as the active target, + * then draws the `source` Render Target to it. It then resets the renderer textures. + * + * This should be done when you need to draw the _final_ results of a pipeline to the game + * canvas, or the next framebuffer in line on the FBO stack. You should only call this once + * in the `onDraw` handler and it should be the final thing called. Be careful not to call + * this if you need to actually use the pipeline shader, instead of the copy shader. In + * those cases, use the `bindAndDraw` method. + * @param source The Render Target to draw from. + */ + copyToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; + + /** + * Copy the `source` Render Target to the `target` Render Target, using the + * given Color Matrix. + * + * The difference between this method and `copyFrame` is that this method + * uses a color matrix shader, where you have full control over the luminance + * values used during the copy. If you don't need this, you can use the faster + * `copyFrame` method instead. + * @param source The source Render Target. + * @param target The target Render Target. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + * @param colorMatrix The Color Matrix to use when performing the draw. + */ + drawFrame(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean, colorMatrix?: Phaser.Display.ColorMatrix): void; + + /** + * Draws the `source1` and `source2` Render Targets to the `target` Render Target + * using a linear blend effect, which is controlled by the `strength` parameter. + * @param source1 The first source Render Target. + * @param source2 The second source Render Target. + * @param target The target Render Target. + * @param strength The strength of the blend. Default 1. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + * @param blendShader The shader to use during the blend copy. + */ + blendFrames(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean, blendShader?: Phaser.Renderer.WebGL.WebGLShader): void; + + /** + * Draws the `source1` and `source2` Render Targets to the `target` Render Target + * using an additive blend effect, which is controlled by the `strength` parameter. + * @param source1 The first source Render Target. + * @param source2 The second source Render Target. + * @param target The target Render Target. + * @param strength The strength of the blend. Default 1. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + blendFramesAdditive(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): void; + + /** + * Clears the given Render Target. + * @param target The Render Target to clear. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + clearFrame(target: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean): void; + + /** + * Set the UV values for the 6 vertices that make up the quad used by the shaders + * in the Utility Pipeline. + * + * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. + * @param uA The u value of vertex A. + * @param vA The v value of vertex A. + * @param uB The u value of vertex B. + * @param vB The v value of vertex B. + * @param uC The u value of vertex C. + * @param vC The v value of vertex C. + * @param uD The u value of vertex D. + * @param vD The v value of vertex D. + */ + setUVs(uA: number, vA: number, uB: number, vB: number, uC: number, vC: number, uD: number, vD: number): void; + + /** + * Sets the vertex UV coordinates of the quad used by the shaders in the Utility Pipeline + * so that they correctly adjust the texture coordinates for a blit frame effect. + * + * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. + * @param source The source Render Target. + * @param target The target Render Target. + */ + setTargetUVs(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget): void; + + /** + * Horizontally flips the UV coordinates of the quad used by the shaders in this + * Utility Pipeline. + * + * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. + */ + flipX(): void; + + /** + * Vertically flips the UV coordinates of the quad used by the shaders in this + * Utility Pipeline. + * + * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. + */ + flipY(): void; + + /** + * Resets the quad vertice UV values to their default settings. + * + * The quad is used by all shaders of the Utility Pipeline. + */ + resetUVs(): void; + + } + + /** + * The Bitmap Mask Pipeline. + */ + const BITMAPMASK_PIPELINE: string; + + /** + * The Light 2D Pipeline. + */ + const LIGHT_PIPELINE: string; + + /** + * The Point Light Pipeline. + */ + const POINTLIGHT_PIPELINE: string; + + /** + * The Single Texture Pipeline. + */ + const SINGLE_PIPELINE: string; + + /** + * The Multi Texture Pipeline. + */ + const MULTI_PIPELINE: string; + + /** + * The Rope Pipeline. + */ + const ROPE_PIPELINE: string; + + /** + * The Graphics and Shapes Pipeline. + */ + const GRAPHICS_PIPELINE: string; + + /** + * The Post FX Pipeline. + */ + const POSTFX_PIPELINE: string; + + /** + * The Utility Pipeline. + */ + const UTILITY_PIPELINE: string; + + namespace Events { + /** + * The WebGLPipeline After Flush Event. + * + * This event is dispatched by a WebGLPipeline right after it has issued a drawArrays command + * and cleared its vertex count. + */ + const AFTER_FLUSH: any; + + /** + * The WebGLPipeline Before Flush Event. + * + * This event is dispatched by a WebGLPipeline right before it is about to + * flush and issue a bufferData and drawArrays command. + */ + const BEFORE_FLUSH: any; + + /** + * The WebGLPipeline Bind Event. + * + * This event is dispatched by a WebGLPipeline when it is bound by the Pipeline Manager. + */ + const BIND: any; + + /** + * The WebGLPipeline Boot Event. + * + * This event is dispatched by a WebGLPipeline when it has completed its `boot` phase. + */ + const BOOT: any; + + /** + * The WebGLPipeline Destroy Event. + * + * This event is dispatched by a WebGLPipeline when it is starting its destroy process. + */ + const DESTROY: any; + + /** + * The WebGLPipeline ReBind Event. + * + * This event is dispatched by a WebGLPipeline when it is re-bound by the Pipeline Manager. + */ + const REBIND: any; + + /** + * The WebGLPipeline Resize Event. + * + * This event is dispatched by a WebGLPipeline when it is resized, usually as a result + * of the Renderer resizing. + */ + const RESIZE: any; + + } + + } + } } - /** - * Phaser Scale Modes. - */ - enum ScaleModes { - /** - * Default Scale Mode (Linear). - */ - DEFAULT, - /** - * Linear Scale Mode. - */ - LINEAR, - /** - * Nearest Scale Mode. - */ - NEAREST, - } - namespace Scale { - /** - * Phaser Scale Manager constants for centering the game canvas. - */ - enum Center { - /** - * The game canvas is not centered within the parent by Phaser. - * You can still center it yourself via CSS. - */ - NO_CENTER, - /** - * The game canvas is centered both horizontally and vertically within the parent. - * To do this, the parent has to have a bounds that can be calculated and not be empty. - * - * Centering is achieved by setting the margin left and top properties of the - * game canvas, and does not factor in any other CSS styles you may have applied. - */ - CENTER_BOTH, - /** - * The game canvas is centered horizontally within the parent. - * To do this, the parent has to have a bounds that can be calculated and not be empty. - * - * Centering is achieved by setting the margin left and top properties of the - * game canvas, and does not factor in any other CSS styles you may have applied. - */ - CENTER_HORIZONTALLY, - /** - * The game canvas is centered both vertically within the parent. - * To do this, the parent has to have a bounds that can be calculated and not be empty. - * - * Centering is achieved by setting the margin left and top properties of the - * game canvas, and does not factor in any other CSS styles you may have applied. - */ - CENTER_VERTICALLY, - } - - /** - * Phaser Scale Manager constants for centering the game canvas. - * - * To find out what each mode does please see [Phaser.Scale.Center]{@link Phaser.Scale.Center}. - */ - type CenterType = Phaser.Scale.Center; - - /** - * Phaser Scale Manager constants for orientation. - */ - enum Orientation { - /** - * A landscape orientation. - */ - LANDSCAPE, - /** - * A portrait orientation. - */ - PORTRAIT, - } - - /** - * Phaser Scale Manager constants for orientation. - * - * To find out what each mode does please see [Phaser.Scale.Orientation]{@link Phaser.Scale.Orientation}. - */ - type OrientationType = Phaser.Scale.Orientation; - - /** - * Phaser Scale Manager constants for the different scale modes available. - */ - enum ScaleModes { - /** - * No scaling happens at all. The canvas is set to the size given in the game config and Phaser doesn't change it - * again from that point on. If you change the canvas size, either via CSS, or directly via code, then you need - * to call the Scale Managers `resize` method to give the new dimensions, or input events will stop working. - */ - NONE, - /** - * The height is automatically adjusted based on the width. - */ - WIDTH_CONTROLS_HEIGHT, - /** - * The width is automatically adjusted based on the height. - */ - HEIGHT_CONTROLS_WIDTH, - /** - * The width and height are automatically adjusted to fit inside the given target area, - * while keeping the aspect ratio. Depending on the aspect ratio there may be some space - * inside the area which is not covered. - */ - FIT, - /** - * The width and height are automatically adjusted to make the size cover the entire target - * area while keeping the aspect ratio. This may extend further out than the target size. - */ - ENVELOP, - /** - * The Canvas is resized to fit all available _parent_ space, regardless of aspect ratio. - */ - RESIZE, - } - - /** - * Phaser Scale Manager constants for the different scale modes available. - * - * To find out what each mode does please see [Phaser.Scale.ScaleModes]{@link Phaser.Scale.ScaleModes}. - */ - type ScaleModeType = Phaser.Scale.ScaleModes; - - /** - * Phaser Scale Manager constants for zoom modes. - */ - enum Zoom { - /** - * The game canvas will not be zoomed by Phaser. - */ - NO_ZOOM, - /** - * The game canvas will be 2x zoomed by Phaser. - */ - ZOOM_2X, - /** - * The game canvas will be 4x zoomed by Phaser. - */ - ZOOM_4X, - /** - * Calculate the zoom value based on the maximum multiplied game size that will - * fit into the parent, or browser window if no parent is set. - */ - MAX_ZOOM, - } - - /** - * Phaser Scale Manager constants for zoom modes. - * - * To find out what each mode does please see [Phaser.Scale.Zoom]{@link Phaser.Scale.Zoom}. - */ - type ZoomType = Phaser.Scale.Zoom; - - namespace Events { - /** - * The Scale Manager has successfully entered fullscreen mode. - */ - const ENTER_FULLSCREEN: any; - - /** - * The Scale Manager tried to enter fullscreen mode but failed. - */ - const FULLSCREEN_FAILED: any; - - /** - * The Scale Manager tried to enter fullscreen mode, but it is unsupported by the browser. - */ - const FULLSCREEN_UNSUPPORTED: any; - - /** - * The Scale Manager was in fullscreen mode, but has since left, either directly via game code, - * or via a user gestured, such as pressing the ESC key. - */ - const LEAVE_FULLSCREEN: any; - - /** - * The Scale Manager Orientation Change Event. - * - * This event is dispatched whenever the Scale Manager detects an orientation change event from the browser. - */ - const ORIENTATION_CHANGE: any; - - /** - * The Scale Manager Resize Event. - * - * This event is dispatched whenever the Scale Manager detects a resize event from the browser. - * It sends three parameters to the callback, each of them being Size components. You can read - * the `width`, `height`, `aspectRatio` and other properties of these components to help with - * scaling your own game content. - */ - const RESIZE: any; - - } - /** * The Scale Manager handles the scaling, resizing and alignment of the game canvas. * @@ -84582,6 +84419,182 @@ declare namespace Phaser { } + /** + * Phaser Scale Manager constants for centering the game canvas. + */ + enum Center { + /** + * The game canvas is not centered within the parent by Phaser. + * You can still center it yourself via CSS. + */ + NO_CENTER, + /** + * The game canvas is centered both horizontally and vertically within the parent. + * To do this, the parent has to have a bounds that can be calculated and not be empty. + * + * Centering is achieved by setting the margin left and top properties of the + * game canvas, and does not factor in any other CSS styles you may have applied. + */ + CENTER_BOTH, + /** + * The game canvas is centered horizontally within the parent. + * To do this, the parent has to have a bounds that can be calculated and not be empty. + * + * Centering is achieved by setting the margin left and top properties of the + * game canvas, and does not factor in any other CSS styles you may have applied. + */ + CENTER_HORIZONTALLY, + /** + * The game canvas is centered both vertically within the parent. + * To do this, the parent has to have a bounds that can be calculated and not be empty. + * + * Centering is achieved by setting the margin left and top properties of the + * game canvas, and does not factor in any other CSS styles you may have applied. + */ + CENTER_VERTICALLY, + } + + /** + * Phaser Scale Manager constants for centering the game canvas. + * + * To find out what each mode does please see [Phaser.Scale.Center]{@link Phaser.Scale.Center}. + */ + type CenterType = Phaser.Scale.Center; + + /** + * Phaser Scale Manager constants for orientation. + */ + enum Orientation { + /** + * A landscape orientation. + */ + LANDSCAPE, + /** + * A portrait orientation. + */ + PORTRAIT, + } + + /** + * Phaser Scale Manager constants for orientation. + * + * To find out what each mode does please see [Phaser.Scale.Orientation]{@link Phaser.Scale.Orientation}. + */ + type OrientationType = Phaser.Scale.Orientation; + + /** + * Phaser Scale Manager constants for the different scale modes available. + */ + enum ScaleModes { + /** + * No scaling happens at all. The canvas is set to the size given in the game config and Phaser doesn't change it + * again from that point on. If you change the canvas size, either via CSS, or directly via code, then you need + * to call the Scale Managers `resize` method to give the new dimensions, or input events will stop working. + */ + NONE, + /** + * The height is automatically adjusted based on the width. + */ + WIDTH_CONTROLS_HEIGHT, + /** + * The width is automatically adjusted based on the height. + */ + HEIGHT_CONTROLS_WIDTH, + /** + * The width and height are automatically adjusted to fit inside the given target area, + * while keeping the aspect ratio. Depending on the aspect ratio there may be some space + * inside the area which is not covered. + */ + FIT, + /** + * The width and height are automatically adjusted to make the size cover the entire target + * area while keeping the aspect ratio. This may extend further out than the target size. + */ + ENVELOP, + /** + * The Canvas is resized to fit all available _parent_ space, regardless of aspect ratio. + */ + RESIZE, + } + + /** + * Phaser Scale Manager constants for the different scale modes available. + * + * To find out what each mode does please see [Phaser.Scale.ScaleModes]{@link Phaser.Scale.ScaleModes}. + */ + type ScaleModeType = Phaser.Scale.ScaleModes; + + /** + * Phaser Scale Manager constants for zoom modes. + */ + enum Zoom { + /** + * The game canvas will not be zoomed by Phaser. + */ + NO_ZOOM, + /** + * The game canvas will be 2x zoomed by Phaser. + */ + ZOOM_2X, + /** + * The game canvas will be 4x zoomed by Phaser. + */ + ZOOM_4X, + /** + * Calculate the zoom value based on the maximum multiplied game size that will + * fit into the parent, or browser window if no parent is set. + */ + MAX_ZOOM, + } + + /** + * Phaser Scale Manager constants for zoom modes. + * + * To find out what each mode does please see [Phaser.Scale.Zoom]{@link Phaser.Scale.Zoom}. + */ + type ZoomType = Phaser.Scale.Zoom; + + namespace Events { + /** + * The Scale Manager has successfully entered fullscreen mode. + */ + const ENTER_FULLSCREEN: any; + + /** + * The Scale Manager tried to enter fullscreen mode but failed. + */ + const FULLSCREEN_FAILED: any; + + /** + * The Scale Manager tried to enter fullscreen mode, but it is unsupported by the browser. + */ + const FULLSCREEN_UNSUPPORTED: any; + + /** + * The Scale Manager was in fullscreen mode, but has since left, either directly via game code, + * or via a user gestured, such as pressing the ESC key. + */ + const LEAVE_FULLSCREEN: any; + + /** + * The Scale Manager Orientation Change Event. + * + * This event is dispatched whenever the Scale Manager detects an orientation change event from the browser. + */ + const ORIENTATION_CHANGE: any; + + /** + * The Scale Manager Resize Event. + * + * This event is dispatched whenever the Scale Manager detects a resize event from the browser. + * It sends three parameters to the callback, each of them being Size components. You can read + * the `width`, `height`, `aspectRatio` and other properties of these components to help with + * scaling your own game content. + */ + const RESIZE: any; + + } + /** * The game canvas is not centered within the parent by Phaser. * You can still center it yourself via CSS. @@ -84683,384 +84696,204 @@ declare namespace Phaser { } + /** + * A base Phaser.Scene class which can be extended for your own use. + * + * You can also define the optional methods {@link Phaser.Types.Scenes.SceneInitCallback init()}, {@link Phaser.Types.Scenes.ScenePreloadCallback preload()}, and {@link Phaser.Types.Scenes.SceneCreateCallback create()}. + */ + class Scene { + /** + * + * @param config Scene specific configuration settings. + */ + constructor(config: string | Phaser.Types.Scenes.SettingsConfig); + + /** + * The Scene Systems. You must never overwrite this property, or all hell will break lose. + */ + sys: Phaser.Scenes.Systems; + + /** + * A reference to the Phaser.Game instance. + * + * This property will only be available if defined in the Scene Injection Map. + */ + game: Phaser.Game; + + /** + * A reference to the global Animation Manager. + * + * This property will only be available if defined in the Scene Injection Map. + */ + anims: Phaser.Animations.AnimationManager; + + /** + * A reference to the global Cache. + * + * This property will only be available if defined in the Scene Injection Map. + */ + cache: Phaser.Cache.CacheManager; + + /** + * A reference to the global Data Manager. + * + * This property will only be available if defined in the Scene Injection Map. + */ + registry: Phaser.Data.DataManager; + + /** + * A reference to the Sound Manager. + * + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + */ + sound: Phaser.Sound.NoAudioSoundManager | Phaser.Sound.HTML5AudioSoundManager | Phaser.Sound.WebAudioSoundManager; + + /** + * A reference to the Texture Manager. + * + * This property will only be available if defined in the Scene Injection Map. + */ + textures: Phaser.Textures.TextureManager; + + /** + * A Scene specific Event Emitter. + * + * This property will only be available if defined in the Scene Injection Map. + */ + events: Phaser.Events.EventEmitter; + + /** + * The Scene Camera Manager. + * + * This property will only be available if defined in the Scene Injection Map. + */ + cameras: Phaser.Cameras.Scene2D.CameraManager; + + /** + * The Scene Game Object Factory. + * + * This property will only be available if defined in the Scene Injection Map. + */ + add: Phaser.GameObjects.GameObjectFactory; + + /** + * The Scene Game Object Creator. + * + * This property will only be available if defined in the Scene Injection Map. + */ + make: Phaser.GameObjects.GameObjectCreator; + + /** + * A reference to the Scene Manager Plugin. + * + * This property will only be available if defined in the Scene Injection Map. + */ + scene: Phaser.Scenes.ScenePlugin; + + /** + * The Game Object Display List belonging to this Scene. + * + * This property will only be available if defined in the Scene Injection Map. + */ + children: Phaser.GameObjects.DisplayList; + + /** + * The Scene Lights Manager Plugin. + * + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + */ + lights: Phaser.GameObjects.LightsManager; + + /** + * A Scene specific Data Manager Plugin. + * + * See the `registry` property for the global Data Manager. + * + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + */ + data: Phaser.Data.DataManager; + + /** + * The Scene Input Manager Plugin. + * + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + */ + input: Phaser.Input.InputPlugin; + + /** + * The Scene Loader Plugin. + * + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + */ + load: Phaser.Loader.LoaderPlugin; + + /** + * The Scene Time and Clock Plugin. + * + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + */ + time: Phaser.Time.Clock; + + /** + * The Scene Tween Manager Plugin. + * + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + */ + tweens: Phaser.Tweens.TweenManager; + + /** + * The Scene Arcade Physics Plugin. + * + * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. + */ + physics: Phaser.Physics.Arcade.ArcadePhysics; + + /** + * The Scene Matter Physics Plugin. + * + * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. + */ + matter: Phaser.Physics.Matter.MatterPhysics; + + /** + * The Facebook Instant Games Plugin. + * + * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. + */ + facebook: Phaser.FacebookInstantGamesPlugin; + + /** + * A reference to the global Scale Manager. + * + * This property will only be available if defined in the Scene Injection Map. + */ + scale: Phaser.Scale.ScaleManager; + + /** + * A reference to the global Plugin Manager. + * + * The Plugin Manager is a global system that allows plugins to register themselves with it, and can then install + * those plugins into Scenes as required. + */ + plugins: Phaser.Plugins.PluginManager; + + /** + * A reference to the renderer instance Phaser is using, either Canvas Renderer or WebGL Renderer. + */ + renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + + /** + * This method should be overridden by your own Scenes. + * + * This method is called once per game step while the scene is running. + * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update(time: number, delta: number): void; + + } + namespace Scenes { - /** - * Scene state. - */ - var PENDING: number; - - /** - * Scene state. - */ - var INIT: number; - - /** - * Scene state. - */ - var START: number; - - /** - * Scene state. - */ - var LOADING: number; - - /** - * Scene state. - */ - var CREATING: number; - - /** - * Scene state. - */ - var RUNNING: number; - - /** - * Scene state. - */ - var PAUSED: number; - - /** - * Scene state. - */ - var SLEEPING: number; - - /** - * Scene state. - */ - var SHUTDOWN: number; - - /** - * Scene state. - */ - var DESTROYED: number; - - namespace Events { - /** - * The Game Object Added to Scene Event. - * - * This event is dispatched when a Game Object is added to a Scene. - * - * Listen for it from a Scene using `this.scene.events.on('addedtoscene', listener)`. - */ - const ADDED_TO_SCENE: any; - - /** - * The Scene Systems Boot Event. - * - * This event is dispatched by a Scene during the Scene Systems boot process. Primarily used by Scene Plugins. - * - * Listen to it from a Scene using `this.scene.events.on('boot', listener)`. - */ - const BOOT: any; - - /** - * The Scene Create Event. - * - * This event is dispatched by a Scene after it has been created by the Scene Manager. - * - * If a Scene has a `create` method then this event is emitted _after_ that has run. - * - * If there is a transition, this event will be fired after the `TRANSITION_START` event. - * - * Listen to it from a Scene using `this.scene.events.on('create', listener)`. - */ - const CREATE: any; - - /** - * The Scene Systems Destroy Event. - * - * This event is dispatched by a Scene during the Scene Systems destroy process. - * - * Listen to it from a Scene using `this.scene.events.on('destroy', listener)`. - * - * You should destroy any resources that may be in use by your Scene in this event handler. - */ - const DESTROY: any; - - /** - * The Scene Systems Pause Event. - * - * This event is dispatched by a Scene when it is paused, either directly via the `pause` method, or as an - * action from another Scene. - * - * Listen to it from a Scene using `this.scene.events.on('pause', listener)`. - */ - const PAUSE: any; - - /** - * The Scene Systems Post Update Event. - * - * This event is dispatched by a Scene during the main game loop step. - * - * The event flow for a single step of a Scene is as follows: - * - * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} - * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} - * 3. The `Scene.update` method is called, if it exists - * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} - * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} - * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} - * - * Listen to it from a Scene using `this.scene.events.on('postupdate', listener)`. - * - * A Scene will only run its step if it is active. - */ - const POST_UPDATE: any; - - /** - * The Scene Systems Pre-Render Event. - * - * This event is dispatched by a Scene during the main game loop step. - * - * The event flow for a single step of a Scene is as follows: - * - * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} - * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} - * 3. The `Scene.update` method is called, if it exists - * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} - * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} - * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} - * - * Listen to this event from a Scene using `this.scene.events.on('prerender', listener)`. - * - * A Scene will only render if it is visible. - * This event is dispatched after the Scene Display List is sorted and before the Scene is rendered. - */ - const PRE_RENDER: any; - - /** - * The Scene Systems Pre Update Event. - * - * This event is dispatched by a Scene during the main game loop step. - * - * The event flow for a single step of a Scene is as follows: - * - * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} - * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} - * 3. The `Scene.update` method is called, if it exists - * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} - * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} - * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} - * - * Listen to it from a Scene using `this.scene.events.on('preupdate', listener)`. - * - * A Scene will only run its step if it is active. - */ - const PRE_UPDATE: any; - - /** - * The Scene Systems Ready Event. - * - * This event is dispatched by a Scene during the Scene Systems start process. - * By this point in the process the Scene is now fully active and rendering. - * This event is meant for your game code to use, as all plugins have responded to the earlier 'start' event. - * - * Listen to it from a Scene using `this.scene.events.on('ready', listener)`. - */ - const READY: any; - - /** - * The Game Object Removed from Scene Event. - * - * This event is dispatched when a Game Object is removed from a Scene. - * - * Listen for it from a Scene using `this.scene.events.on('removedfromscene', listener)`. - */ - const REMOVED_FROM_SCENE: any; - - /** - * The Scene Systems Render Event. - * - * This event is dispatched by a Scene during the main game loop step. - * - * The event flow for a single step of a Scene is as follows: - * - * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} - * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} - * 3. The `Scene.update` method is called, if it exists - * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} - * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} - * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} - * - * Listen to it from a Scene using `this.scene.events.on('render', listener)`. - * - * A Scene will only render if it is visible. - * By the time this event is dispatched, the Scene will have already been rendered. - */ - const RENDER: any; - - /** - * The Scene Systems Resume Event. - * - * This event is dispatched by a Scene when it is resumed from a paused state, either directly via the `resume` method, - * or as an action from another Scene. - * - * Listen to it from a Scene using `this.scene.events.on('resume', listener)`. - */ - const RESUME: any; - - /** - * The Scene Systems Shutdown Event. - * - * This event is dispatched by a Scene during the Scene Systems shutdown process. - * - * Listen to it from a Scene using `this.scene.events.on('shutdown', listener)`. - * - * You should free-up any resources that may be in use by your Scene in this event handler, on the understanding - * that the Scene may, at any time, become active again. A shutdown Scene is not 'destroyed', it's simply not - * currently active. Use the [DESTROY]{@linkcode Phaser.Scenes.Events#event:DESTROY} event to completely clear resources. - */ - const SHUTDOWN: any; - - /** - * The Scene Systems Sleep Event. - * - * This event is dispatched by a Scene when it is sent to sleep, either directly via the `sleep` method, - * or as an action from another Scene. - * - * Listen to it from a Scene using `this.scene.events.on('sleep', listener)`. - */ - const SLEEP: any; - - /** - * The Scene Systems Start Event. - * - * This event is dispatched by a Scene during the Scene Systems start process. Primarily used by Scene Plugins. - * - * Listen to it from a Scene using `this.scene.events.on('start', listener)`. - */ - const START: any; - - /** - * The Scene Transition Complete Event. - * - * This event is dispatched by the Target Scene of a transition. - * - * It happens when the transition process has completed. This occurs when the duration timer equals or exceeds the duration - * of the transition. - * - * Listen to it from a Scene using `this.scene.events.on('transitioncomplete', listener)`. - * - * The Scene Transition event flow is as follows: - * - * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. - * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. - * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... - * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. - * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. - */ - const TRANSITION_COMPLETE: any; - - /** - * The Scene Transition Init Event. - * - * This event is dispatched by the Target Scene of a transition. - * - * It happens immediately after the `Scene.init` method is called. If the Scene does not have an `init` method, - * this event is not dispatched. - * - * Listen to it from a Scene using `this.scene.events.on('transitioninit', listener)`. - * - * The Scene Transition event flow is as follows: - * - * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. - * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. - * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... - * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. - * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. - */ - const TRANSITION_INIT: any; - - /** - * The Scene Transition Out Event. - * - * This event is dispatched by a Scene when it initiates a transition to another Scene. - * - * Listen to it from a Scene using `this.scene.events.on('transitionout', listener)`. - * - * The Scene Transition event flow is as follows: - * - * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. - * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. - * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... - * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. - * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. - */ - const TRANSITION_OUT: any; - - /** - * The Scene Transition Start Event. - * - * This event is dispatched by the Target Scene of a transition, only if that Scene was not asleep. - * - * It happens immediately after the `Scene.create` method is called. If the Scene does not have a `create` method, - * this event is dispatched anyway. - * - * If the Target Scene was sleeping then the [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} event is - * dispatched instead of this event. - * - * Listen to it from a Scene using `this.scene.events.on('transitionstart', listener)`. - * - * The Scene Transition event flow is as follows: - * - * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. - * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. - * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... - * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. - * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. - */ - const TRANSITION_START: any; - - /** - * The Scene Transition Wake Event. - * - * This event is dispatched by the Target Scene of a transition, only if that Scene was asleep before - * the transition began. If the Scene was not asleep the [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} event is dispatched instead. - * - * Listen to it from a Scene using `this.scene.events.on('transitionwake', listener)`. - * - * The Scene Transition event flow is as follows: - * - * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. - * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. - * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... - * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. - * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. - */ - const TRANSITION_WAKE: any; - - /** - * The Scene Systems Update Event. - * - * This event is dispatched by a Scene during the main game loop step. - * - * The event flow for a single step of a Scene is as follows: - * - * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} - * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} - * 3. The `Scene.update` method is called, if it exists - * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} - * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} - * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} - * - * Listen to it from a Scene using `this.scene.events.on('update', listener)`. - * - * A Scene will only run its step if it is active. - */ - const UPDATE: any; - - /** - * The Scene Systems Wake Event. - * - * This event is dispatched by a Scene when it is woken from sleep, either directly via the `wake` method, - * or as an action from another Scene. - * - * Listen to it from a Scene using `this.scene.events.on('wake', listener)`. - */ - const WAKE: any; - - } - /** * Builds an array of which physics plugins should be activated for the given Scene. * @param sys The scene system to get the physics systems of. @@ -85988,202 +85821,382 @@ declare namespace Phaser { } - } - - /** - * A base Phaser.Scene class which can be extended for your own use. - * - * You can also define the optional methods {@link Phaser.Types.Scenes.SceneInitCallback init()}, {@link Phaser.Types.Scenes.ScenePreloadCallback preload()}, and {@link Phaser.Types.Scenes.SceneCreateCallback create()}. - */ - class Scene { /** - * - * @param config Scene specific configuration settings. + * Scene state. */ - constructor(config: string | Phaser.Types.Scenes.SettingsConfig); + var PENDING: number; /** - * The Scene Systems. You must never overwrite this property, or all hell will break lose. + * Scene state. */ - sys: Phaser.Scenes.Systems; + var INIT: number; /** - * A reference to the Phaser.Game instance. - * - * This property will only be available if defined in the Scene Injection Map. + * Scene state. */ - game: Phaser.Game; + var START: number; /** - * A reference to the global Animation Manager. - * - * This property will only be available if defined in the Scene Injection Map. + * Scene state. */ - anims: Phaser.Animations.AnimationManager; + var LOADING: number; /** - * A reference to the global Cache. - * - * This property will only be available if defined in the Scene Injection Map. + * Scene state. */ - cache: Phaser.Cache.CacheManager; + var CREATING: number; /** - * A reference to the global Data Manager. - * - * This property will only be available if defined in the Scene Injection Map. + * Scene state. */ - registry: Phaser.Data.DataManager; + var RUNNING: number; /** - * A reference to the Sound Manager. - * - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + * Scene state. */ - sound: Phaser.Sound.NoAudioSoundManager | Phaser.Sound.HTML5AudioSoundManager | Phaser.Sound.WebAudioSoundManager; + var PAUSED: number; /** - * A reference to the Texture Manager. - * - * This property will only be available if defined in the Scene Injection Map. + * Scene state. */ - textures: Phaser.Textures.TextureManager; + var SLEEPING: number; /** - * A Scene specific Event Emitter. - * - * This property will only be available if defined in the Scene Injection Map. + * Scene state. */ - events: Phaser.Events.EventEmitter; + var SHUTDOWN: number; /** - * The Scene Camera Manager. - * - * This property will only be available if defined in the Scene Injection Map. + * Scene state. */ - cameras: Phaser.Cameras.Scene2D.CameraManager; + var DESTROYED: number; - /** - * The Scene Game Object Factory. - * - * This property will only be available if defined in the Scene Injection Map. - */ - add: Phaser.GameObjects.GameObjectFactory; + namespace Events { + /** + * The Game Object Added to Scene Event. + * + * This event is dispatched when a Game Object is added to a Scene. + * + * Listen for it from a Scene using `this.scene.events.on('addedtoscene', listener)`. + */ + const ADDED_TO_SCENE: any; - /** - * The Scene Game Object Creator. - * - * This property will only be available if defined in the Scene Injection Map. - */ - make: Phaser.GameObjects.GameObjectCreator; + /** + * The Scene Systems Boot Event. + * + * This event is dispatched by a Scene during the Scene Systems boot process. Primarily used by Scene Plugins. + * + * Listen to it from a Scene using `this.scene.events.on('boot', listener)`. + */ + const BOOT: any; - /** - * A reference to the Scene Manager Plugin. - * - * This property will only be available if defined in the Scene Injection Map. - */ - scene: Phaser.Scenes.ScenePlugin; + /** + * The Scene Create Event. + * + * This event is dispatched by a Scene after it has been created by the Scene Manager. + * + * If a Scene has a `create` method then this event is emitted _after_ that has run. + * + * If there is a transition, this event will be fired after the `TRANSITION_START` event. + * + * Listen to it from a Scene using `this.scene.events.on('create', listener)`. + */ + const CREATE: any; - /** - * The Game Object Display List belonging to this Scene. - * - * This property will only be available if defined in the Scene Injection Map. - */ - children: Phaser.GameObjects.DisplayList; + /** + * The Scene Systems Destroy Event. + * + * This event is dispatched by a Scene during the Scene Systems destroy process. + * + * Listen to it from a Scene using `this.scene.events.on('destroy', listener)`. + * + * You should destroy any resources that may be in use by your Scene in this event handler. + */ + const DESTROY: any; - /** - * The Scene Lights Manager Plugin. - * - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - */ - lights: Phaser.GameObjects.LightsManager; + /** + * The Scene Systems Pause Event. + * + * This event is dispatched by a Scene when it is paused, either directly via the `pause` method, or as an + * action from another Scene. + * + * Listen to it from a Scene using `this.scene.events.on('pause', listener)`. + */ + const PAUSE: any; - /** - * A Scene specific Data Manager Plugin. - * - * See the `registry` property for the global Data Manager. - * - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - */ - data: Phaser.Data.DataManager; + /** + * The Scene Systems Post Update Event. + * + * This event is dispatched by a Scene during the main game loop step. + * + * The event flow for a single step of a Scene is as follows: + * + * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} + * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} + * 3. The `Scene.update` method is called, if it exists + * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} + * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} + * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} + * + * Listen to it from a Scene using `this.scene.events.on('postupdate', listener)`. + * + * A Scene will only run its step if it is active. + */ + const POST_UPDATE: any; - /** - * The Scene Input Manager Plugin. - * - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - */ - input: Phaser.Input.InputPlugin; + /** + * The Scene Systems Pre-Render Event. + * + * This event is dispatched by a Scene during the main game loop step. + * + * The event flow for a single step of a Scene is as follows: + * + * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} + * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} + * 3. The `Scene.update` method is called, if it exists + * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} + * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} + * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} + * + * Listen to this event from a Scene using `this.scene.events.on('prerender', listener)`. + * + * A Scene will only render if it is visible. + * This event is dispatched after the Scene Display List is sorted and before the Scene is rendered. + */ + const PRE_RENDER: any; - /** - * The Scene Loader Plugin. - * - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - */ - load: Phaser.Loader.LoaderPlugin; + /** + * The Scene Systems Pre Update Event. + * + * This event is dispatched by a Scene during the main game loop step. + * + * The event flow for a single step of a Scene is as follows: + * + * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} + * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} + * 3. The `Scene.update` method is called, if it exists + * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} + * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} + * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} + * + * Listen to it from a Scene using `this.scene.events.on('preupdate', listener)`. + * + * A Scene will only run its step if it is active. + */ + const PRE_UPDATE: any; - /** - * The Scene Time and Clock Plugin. - * - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - */ - time: Phaser.Time.Clock; + /** + * The Scene Systems Ready Event. + * + * This event is dispatched by a Scene during the Scene Systems start process. + * By this point in the process the Scene is now fully active and rendering. + * This event is meant for your game code to use, as all plugins have responded to the earlier 'start' event. + * + * Listen to it from a Scene using `this.scene.events.on('ready', listener)`. + */ + const READY: any; - /** - * The Scene Tween Manager Plugin. - * - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - */ - tweens: Phaser.Tweens.TweenManager; + /** + * The Game Object Removed from Scene Event. + * + * This event is dispatched when a Game Object is removed from a Scene. + * + * Listen for it from a Scene using `this.scene.events.on('removedfromscene', listener)`. + */ + const REMOVED_FROM_SCENE: any; - /** - * The Scene Arcade Physics Plugin. - * - * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. - */ - physics: Phaser.Physics.Arcade.ArcadePhysics; + /** + * The Scene Systems Render Event. + * + * This event is dispatched by a Scene during the main game loop step. + * + * The event flow for a single step of a Scene is as follows: + * + * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} + * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} + * 3. The `Scene.update` method is called, if it exists + * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} + * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} + * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} + * + * Listen to it from a Scene using `this.scene.events.on('render', listener)`. + * + * A Scene will only render if it is visible. + * By the time this event is dispatched, the Scene will have already been rendered. + */ + const RENDER: any; - /** - * The Scene Matter Physics Plugin. - * - * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. - */ - matter: Phaser.Physics.Matter.MatterPhysics; + /** + * The Scene Systems Resume Event. + * + * This event is dispatched by a Scene when it is resumed from a paused state, either directly via the `resume` method, + * or as an action from another Scene. + * + * Listen to it from a Scene using `this.scene.events.on('resume', listener)`. + */ + const RESUME: any; - /** - * The Facebook Instant Games Plugin. - * - * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. - */ - facebook: Phaser.FacebookInstantGamesPlugin; + /** + * The Scene Systems Shutdown Event. + * + * This event is dispatched by a Scene during the Scene Systems shutdown process. + * + * Listen to it from a Scene using `this.scene.events.on('shutdown', listener)`. + * + * You should free-up any resources that may be in use by your Scene in this event handler, on the understanding + * that the Scene may, at any time, become active again. A shutdown Scene is not 'destroyed', it's simply not + * currently active. Use the [DESTROY]{@linkcode Phaser.Scenes.Events#event:DESTROY} event to completely clear resources. + */ + const SHUTDOWN: any; - /** - * A reference to the global Scale Manager. - * - * This property will only be available if defined in the Scene Injection Map. - */ - scale: Phaser.Scale.ScaleManager; + /** + * The Scene Systems Sleep Event. + * + * This event is dispatched by a Scene when it is sent to sleep, either directly via the `sleep` method, + * or as an action from another Scene. + * + * Listen to it from a Scene using `this.scene.events.on('sleep', listener)`. + */ + const SLEEP: any; - /** - * A reference to the global Plugin Manager. - * - * The Plugin Manager is a global system that allows plugins to register themselves with it, and can then install - * those plugins into Scenes as required. - */ - plugins: Phaser.Plugins.PluginManager; + /** + * The Scene Systems Start Event. + * + * This event is dispatched by a Scene during the Scene Systems start process. Primarily used by Scene Plugins. + * + * Listen to it from a Scene using `this.scene.events.on('start', listener)`. + */ + const START: any; - /** - * A reference to the renderer instance Phaser is using, either Canvas Renderer or WebGL Renderer. - */ - renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + /** + * The Scene Transition Complete Event. + * + * This event is dispatched by the Target Scene of a transition. + * + * It happens when the transition process has completed. This occurs when the duration timer equals or exceeds the duration + * of the transition. + * + * Listen to it from a Scene using `this.scene.events.on('transitioncomplete', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. + */ + const TRANSITION_COMPLETE: any; - /** - * This method should be overridden by your own Scenes. - * - * This method is called once per game step while the scene is running. - * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. - * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. - */ - update(time: number, delta: number): void; + /** + * The Scene Transition Init Event. + * + * This event is dispatched by the Target Scene of a transition. + * + * It happens immediately after the `Scene.init` method is called. If the Scene does not have an `init` method, + * this event is not dispatched. + * + * Listen to it from a Scene using `this.scene.events.on('transitioninit', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. + */ + const TRANSITION_INIT: any; + + /** + * The Scene Transition Out Event. + * + * This event is dispatched by a Scene when it initiates a transition to another Scene. + * + * Listen to it from a Scene using `this.scene.events.on('transitionout', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. + */ + const TRANSITION_OUT: any; + + /** + * The Scene Transition Start Event. + * + * This event is dispatched by the Target Scene of a transition, only if that Scene was not asleep. + * + * It happens immediately after the `Scene.create` method is called. If the Scene does not have a `create` method, + * this event is dispatched anyway. + * + * If the Target Scene was sleeping then the [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} event is + * dispatched instead of this event. + * + * Listen to it from a Scene using `this.scene.events.on('transitionstart', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. + */ + const TRANSITION_START: any; + + /** + * The Scene Transition Wake Event. + * + * This event is dispatched by the Target Scene of a transition, only if that Scene was asleep before + * the transition began. If the Scene was not asleep the [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} event is dispatched instead. + * + * Listen to it from a Scene using `this.scene.events.on('transitionwake', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. + */ + const TRANSITION_WAKE: any; + + /** + * The Scene Systems Update Event. + * + * This event is dispatched by a Scene during the main game loop step. + * + * The event flow for a single step of a Scene is as follows: + * + * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} + * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} + * 3. The `Scene.update` method is called, if it exists + * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} + * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} + * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} + * + * Listen to it from a Scene using `this.scene.events.on('update', listener)`. + * + * A Scene will only run its step if it is active. + */ + const UPDATE: any; + + /** + * The Scene Systems Wake Event. + * + * This event is dispatched by a Scene when it is woken from sleep, either directly via the `wake` method, + * or as an action from another Scene. + * + * Listen to it from a Scene using `this.scene.events.on('wake', listener)`. + */ + const WAKE: any; + + } } @@ -86510,6 +86523,14 @@ declare namespace Phaser { } + /** + * Creates a Web Audio, HTML5 Audio or No Audio Sound Manager based on config and device settings. + * + * Be aware of https://developers.google.com/web/updates/2017/09/autoplay-policy-changes + * @param game Reference to the current game instance. + */ + function SoundManagerCreator(game: Phaser.Game): Phaser.Sound.HTML5AudioSoundManager | Phaser.Sound.WebAudioSoundManager | Phaser.Sound.NoAudioSoundManager; + namespace Events { /** * The Sound Complete Event. @@ -87179,14 +87200,6 @@ declare namespace Phaser { } - /** - * Creates a Web Audio, HTML5 Audio or No Audio Sound Manager based on config and device settings. - * - * Be aware of https://developers.google.com/web/updates/2017/09/autoplay-policy-changes - * @param game Reference to the current game instance. - */ - function SoundManagerCreator(game: Phaser.Game): Phaser.Sound.HTML5AudioSoundManager | Phaser.Sound.WebAudioSoundManager | Phaser.Sound.NoAudioSoundManager; - /** * Web Audio API implementation of the sound. */ @@ -87509,31 +87522,6 @@ declare namespace Phaser { } namespace Structs { - namespace Events { - /** - * The Process Queue Add Event. - * - * This event is dispatched by a Process Queue when a new item is successfully moved to its active list. - * - * You will most commonly see this used by a Scene's Update List when a new Game Object has been added. - * - * In that instance, listen to this event from within a Scene using: `this.sys.updateList.on('add', listener)`. - */ - const PROCESS_QUEUE_ADD: any; - - /** - * The Process Queue Remove Event. - * - * This event is dispatched by a Process Queue when a new item is successfully removed from its active list. - * - * You will most commonly see this used by a Scene's Update List when a Game Object has been removed. - * - * In that instance, listen to this event from within a Scene using: `this.sys.updateList.on('remove', listener)`. - */ - const PROCESS_QUEUE_REMOVE: any; - - } - /** * List is a generic implementation of an ordered list which contains utility methods for retrieving, manipulating, and iterating items. */ @@ -88431,6 +88419,31 @@ declare namespace Phaser { } + namespace Events { + /** + * The Process Queue Add Event. + * + * This event is dispatched by a Process Queue when a new item is successfully moved to its active list. + * + * You will most commonly see this used by a Scene's Update List when a new Game Object has been added. + * + * In that instance, listen to this event from within a Scene using: `this.sys.updateList.on('add', listener)`. + */ + const PROCESS_QUEUE_ADD: any; + + /** + * The Process Queue Remove Event. + * + * This event is dispatched by a Process Queue when a new item is successfully removed from its active list. + * + * You will most commonly see this used by a Scene's Update List when a Game Object has been removed. + * + * In that instance, listen to this event from within a Scene using: `this.sys.updateList.on('remove', listener)`. + */ + const PROCESS_QUEUE_REMOVE: any; + + } + } namespace Textures { @@ -88650,75 +88663,6 @@ declare namespace Phaser { } - /** - * Filter Types. - */ - enum FilterMode { - /** - * Linear filter type. - */ - LINEAR, - /** - * Nearest neighbor filter type. - */ - NEAREST, - } - - namespace Events { - /** - * The Texture Add Event. - * - * This event is dispatched by the Texture Manager when a texture is added to it. - * - * Listen to this event from within a Scene using: `this.textures.on('addtexture', listener)`. - */ - const ADD: any; - - /** - * The Texture Load Error Event. - * - * This event is dispatched by the Texture Manager when a texture it requested to load failed. - * This only happens when base64 encoded textures fail. All other texture types are loaded via the Loader Plugin. - * - * Listen to this event from within a Scene using: `this.textures.on('onerror', listener)`. - */ - const ERROR: any; - - /** - * The Texture Load Event. - * - * This event is dispatched by the Texture Manager when a texture has finished loading on it. - * This only happens for base64 encoded textures. All other texture types are loaded via the Loader Plugin. - * - * Listen to this event from within a Scene using: `this.textures.on('onload', listener)`. - * - * This event is dispatched after the [ADD]{@linkcode Phaser.Textures.Events#event:ADD} event. - */ - const LOAD: any; - - /** - * This internal event signifies that the Texture Manager is now ready and the Game can continue booting. - * - * When a Phaser Game instance is booting for the first time, the Texture Manager has to wait on a couple of non-blocking - * async events before it's fully ready to carry on. When those complete the Texture Manager emits this event via the Game - * instance, which tells the Game to carry on booting. - */ - const READY: any; - - /** - * The Texture Remove Event. - * - * This event is dispatched by the Texture Manager when a texture is removed from it. - * - * Listen to this event from within a Scene using: `this.textures.on('removetexture', listener)`. - * - * If you have any Game Objects still using the removed texture, they will start throwing - * errors the next time they try to render. Be sure to clear all use of the texture in this event handler. - */ - const REMOVE: any; - - } - /** * A Frame is a section of a Texture. */ @@ -88991,19 +88935,6 @@ declare namespace Phaser { } - /** - * Linear filter type. - */ - const LINEAR: number; - - /** - * Nearest Neighbor filter type. - */ - const NEAREST: number; - - namespace Parsers { - } - /** * A Texture consists of a source, usually an Image from the Cache, and a collection of Frames. * The Frames represent the different areas of the Texture. For example a texture atlas @@ -89689,802 +89620,91 @@ declare namespace Phaser { } + /** + * Filter Types. + */ + enum FilterMode { + /** + * Linear filter type. + */ + LINEAR, + /** + * Nearest neighbor filter type. + */ + NEAREST, + } + + namespace Events { + /** + * The Texture Add Event. + * + * This event is dispatched by the Texture Manager when a texture is added to it. + * + * Listen to this event from within a Scene using: `this.textures.on('addtexture', listener)`. + */ + const ADD: any; + + /** + * The Texture Load Error Event. + * + * This event is dispatched by the Texture Manager when a texture it requested to load failed. + * This only happens when base64 encoded textures fail. All other texture types are loaded via the Loader Plugin. + * + * Listen to this event from within a Scene using: `this.textures.on('onerror', listener)`. + */ + const ERROR: any; + + /** + * The Texture Load Event. + * + * This event is dispatched by the Texture Manager when a texture has finished loading on it. + * This only happens for base64 encoded textures. All other texture types are loaded via the Loader Plugin. + * + * Listen to this event from within a Scene using: `this.textures.on('onload', listener)`. + * + * This event is dispatched after the [ADD]{@linkcode Phaser.Textures.Events#event:ADD} event. + */ + const LOAD: any; + + /** + * This internal event signifies that the Texture Manager is now ready and the Game can continue booting. + * + * When a Phaser Game instance is booting for the first time, the Texture Manager has to wait on a couple of non-blocking + * async events before it's fully ready to carry on. When those complete the Texture Manager emits this event via the Game + * instance, which tells the Game to carry on booting. + */ + const READY: any; + + /** + * The Texture Remove Event. + * + * This event is dispatched by the Texture Manager when a texture is removed from it. + * + * Listen to this event from within a Scene using: `this.textures.on('removetexture', listener)`. + * + * If you have any Game Objects still using the removed texture, they will start throwing + * errors the next time they try to render. Be sure to clear all use of the texture in this event handler. + */ + const REMOVE: any; + + } + + /** + * Linear filter type. + */ + const LINEAR: number; + + /** + * Nearest Neighbor filter type. + */ + const NEAREST: number; + + namespace Parsers { + } + } namespace Tilemaps { - namespace Components { - /** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. - * @param tileX The x coordinate. - * @param tileY The y coordinate. - * @param layer The Tilemap Layer to act upon. - */ - function CalculateFacesAt(tileX: number, tileY: number, layer: Phaser.Tilemaps.LayerData): void; - - /** - * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the - * layer. Interesting faces are used internally for optimizing collisions against tiles. This method - * is mostly used internally. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param layer The Tilemap Layer to act upon. - */ - function CalculateFacesWithin(tileX: number, tileY: number, width: number, height: number, layer: Phaser.Tilemaps.LayerData): void; - - /** - * Checks if the given tile coordinate is within the isometric layer bounds, or not. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param layer The Tilemap Layer to check against. - * @param camera The Camera to run the cull check against. - */ - function CheckIsoBounds(tileX: number, tileY: number, layer: Phaser.Tilemaps.LayerData, camera?: Phaser.Cameras.Scene2D.Camera): boolean; - - /** - * Copies the tiles in the source rectangular area to a new destination (all specified in tile - * coordinates) within the layer. This copies all tile properties & recalculates collision - * information in the destination region. - * @param srcTileX The x coordinate of the area to copy from, in tiles, not pixels. - * @param srcTileY The y coordinate of the area to copy from, in tiles, not pixels. - * @param width The width of the area to copy, in tiles, not pixels. - * @param height The height of the area to copy, in tiles, not pixels. - * @param destTileX The x coordinate of the area to copy to, in tiles, not pixels. - * @param destTileY The y coordinate of the area to copy to, in tiles, not pixels. - * @param recalculateFaces `true` if the faces data should be recalculated. - * @param layer The Tilemap Layer to act upon. - */ - function Copy(srcTileX: number, srcTileY: number, width: number, height: number, destTileX: number, destTileY: number, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; - - /** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * @param indexes The tile index, or array of indexes, to create Sprites from. - * @param replacements The tile index, or array of indexes, to change a converted tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a one-to-one mapping with the indexes array. - * @param spriteConfig The config object to pass into the Sprite creator (i.e. scene.make.sprite). - * @param scene The Scene to create the Sprites within. - * @param camera The Camera to use when determining the world XY - * @param layer The Tilemap Layer to act upon. - */ - function CreateFromTiles(indexes: number | number[], replacements: number | number[], spriteConfig: Phaser.Types.GameObjects.Sprite.SpriteConfig, scene: Phaser.Scene, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.GameObjects.Sprite[]; - - /** - * Returns the bounds in the given orthogonal layer that are within the cameras viewport. - * This is used internally by the cull tiles function. - * @param layer The Tilemap Layer to act upon. - * @param camera The Camera to run the cull check against. - */ - function CullBounds(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera): Phaser.Geom.Rectangle; - - /** - * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. - * @param layer The Tilemap Layer to act upon. - * @param camera The Camera to run the cull check against. - * @param outputArray An optional array to store the Tile objects within. - * @param renderOrder The rendering order constant. Default 0. - */ - function CullTiles(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera, outputArray?: any[], renderOrder?: number): Phaser.Tilemaps.Tile[]; - - /** - * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the - * specified index. Tiles will be set to collide if the given index is a colliding index. - * Collision information in the region will be recalculated. - * @param index The tile index to fill the area with. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param recalculateFaces `true` if the faces data should be recalculated. - * @param layer The tile layer to use. If not given the current layer is used. - */ - function Fill(index: number, tileX: number, tileY: number, width: number, height: number, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * @param callback The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param context The context under which the callback should be run. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param layer The Tilemap Layer to act upon. - */ - function FilterTiles(callback: Function, context: object, tileX: number, tileY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; - - /** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * @param index The tile index value to search for. - * @param skip The number of times to skip a matching tile before returning. - * @param reverse If true it will scan the layer in reverse, starting at the bottom-right. Otherwise it scans from the top-left. - * @param layer The Tilemap Layer to act upon. - */ - function FindByIndex(index: number, skip: number, reverse: boolean, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; - - /** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. - * @param context The context under which the callback should be run. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param layer The Tilemap Layer to act upon. - */ - function FindTile(callback: FindTileCallback, context: object, tileX: number, tileY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. - * @param context The context under which the callback should be run. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param layer The Tilemap Layer to act upon. - */ - function ForEachTile(callback: EachTileCallback, context: object, tileX: number, tileY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, layer: Phaser.Tilemaps.LayerData): void; - - /** - * Gets the correct function to use to cull tiles, based on the map orientation. - * @param orientation The Tilemap orientation constant. - */ - function GetCullTilesFunction(orientation: number): Function; - - /** - * Gets a tile at the given tile coordinates from the given layer. - * @param tileX X position to get the tile from (given in tile units, not pixels). - * @param tileY Y position to get the tile from (given in tile units, not pixels). - * @param nonNull If true getTile won't return null for empty tiles, but a Tile object with an index of -1. - * @param layer The Tilemap Layer to act upon. - */ - function GetTileAt(tileX: number, tileY: number, nonNull: boolean, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; - - /** - * Gets a tile at the given world coordinates from the given layer. - * @param worldX X position to get the tile from (given in pixels) - * @param worldY Y position to get the tile from (given in pixels) - * @param nonNull If true, function won't return null for empty tiles, but a Tile object with an index of -1. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function GetTileAtWorldXY(worldX: number, worldY: number, nonNull: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; - - /** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param layer The Tilemap Layer to act upon. - */ - function GetTilesWithin(tileX: number, tileY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; - - /** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * @param shape A shape in world (pixel) coordinates - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function GetTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; - - /** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * @param worldX The world x coordinate for the top-left of the area. - * @param worldY The world y coordinate for the top-left of the area. - * @param width The width of the area. - * @param height The height of the area. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param camera The Camera to use when factoring in which tiles to return. - * @param layer The Tilemap Layer to act upon. - */ - function GetTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; - - /** - * Gets the correct function to use to translate tiles, based on the map orientation. - * @param orientation The Tilemap orientation constant. - */ - function GetTileToWorldXFunction(orientation: number): Function; - - /** - * Gets the correct function to use to translate tiles, based on the map orientation. - * @param orientation The Tilemap orientation constant. - */ - function GetTileToWorldXYFunction(orientation: number): Function; - - /** - * Gets the correct function to use to translate tiles, based on the map orientation. - * @param orientation The Tilemap orientation constant. - */ - function GetTileToWorldYFunction(orientation: number): Function; - - /** - * Gets the correct function to use to translate tiles, based on the map orientation. - * @param orientation The Tilemap orientation constant. - */ - function GetWorldToTileXFunction(orientation: number): Function; - - /** - * Gets the correct function to use to translate tiles, based on the map orientation. - * @param orientation The Tilemap orientation constant. - */ - function GetWorldToTileXYFunction(orientation: number): Function; - - /** - * Gets the correct function to use to translate tiles, based on the map orientation. - * @param orientation The Tilemap orientation constant. - */ - function GetWorldToTileYFunction(orientation: number): Function; - - /** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * @param tileX X position to get the tile from (given in tile units, not pixels). - * @param tileY Y position to get the tile from (given in tile units, not pixels). - * @param layer The Tilemap Layer to act upon. - */ - function HasTileAt(tileX: number, tileY: number, layer: Phaser.Tilemaps.LayerData): boolean; - - /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * @param worldX The X coordinate of the world position. - * @param worldY The Y coordinate of the world position. - * @param camera The Camera to use when factoring in which tiles to return. - * @param layer The Tilemap Layer to act upon. - */ - function HasTileAtWorldXY(worldX: number, worldY: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): boolean; - - /** - * Returns the bounds in the given layer that are within the camera's viewport. - * This is used internally by the cull tiles function. - * @param layer The Tilemap Layer to act upon. - * @param camera The Camera to run the cull check against. - */ - function HexagonalCullBounds(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera): object; - - /** - * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. - * @param layer The Tilemap Layer to act upon. - * @param camera The Camera to run the cull check against. - * @param outputArray An optional array to store the Tile objects within. - * @param renderOrder The rendering order constant. Default 0. - */ - function HexagonalCullTiles(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera, outputArray?: any[], renderOrder?: number): Phaser.Tilemaps.Tile[]; - - /** - * Converts from hexagonal tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function HexagonalTileToWorldXY(tileX: number, tileY: number, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; - - /** - * Converts from hexagonal tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layer's position, scale and scroll. - * @param tileY The y coordinate, in tiles, not pixels. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function HexagonalTileToWorldY(tileY: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; - - /** - * Converts from world XY coordinates (pixels) to hexagonal tile XY coordinates (tile units), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param worldX The x coordinate to be converted, in pixels, not tiles. - * @param worldY The y coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinates down to the nearest integer. - * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function HexagonalWorldToTileXY(worldX: number, worldY: number, snapToFloor: boolean, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; - - /** - * Converts from world Y coordinates (pixels) to hexagonal tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. - * @param worldY The y coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function HexagonalWorldToTileY(worldY: number, snapToFloor: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; - - /** - * Checks if the given tile coordinates are within the bounds of the layer. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param layer The Tilemap Layer to act upon. - */ - function IsInLayerBounds(tileX: number, tileY: number, layer: Phaser.Tilemaps.LayerData): boolean; - - /** - * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. - * @param layer The Tilemap Layer to act upon. - * @param camera The Camera to run the cull check against. - * @param outputArray An optional array to store the Tile objects within. - * @param renderOrder The rendering order constant. Default 0. - */ - function IsometricCullTiles(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera, outputArray?: any[], renderOrder?: number): Phaser.Tilemaps.Tile[]; - - /** - * Converts from isometric tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function IsometricTileToWorldXY(tileX: number, tileY: number, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; - - /** - * Converts from world XY coordinates (pixels) to isometric tile XY coordinates (tile units), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param worldX The x coordinate to be converted, in pixels, not tiles. - * @param worldY The y coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. - * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function IsometricWorldToTileXY(worldX: number, worldY: number, snapToFloor: boolean, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; - - /** - * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index - * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified - * location. If you pass in an index, only the index at the specified location will be changed. - * Collision information will be recalculated at the specified location. - * @param tile The index of this tile to set or a Tile object. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param recalculateFaces `true` if the faces data should be recalculated. - * @param layer The Tilemap Layer to act upon. - */ - function PutTileAt(tile: number | Phaser.Tilemaps.Tile, tileX: number, tileY: number, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; - - /** - * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either - * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the - * specified location. If you pass in an index, only the index at the specified location will be - * changed. Collision information will be recalculated at the specified location. - * @param tile The index of this tile to set or a Tile object. - * @param worldX The x coordinate, in pixels. - * @param worldY The y coordinate, in pixels. - * @param recalculateFaces `true` if the faces data should be recalculated. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function PutTileAtWorldXY(tile: number | Phaser.Tilemaps.Tile, worldX: number, worldY: number, recalculateFaces: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; - - /** - * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified - * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, - * all attributes will be copied over to the specified location. If you pass in an index, only the - * index at the specified location will be changed. Collision information will be recalculated - * within the region tiles were changed. - * @param tile A row (array) or grid (2D array) of Tiles or tile indexes to place. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param recalculateFaces `true` if the faces data should be recalculated. - * @param layer The Tilemap Layer to act upon. - */ - function PutTilesAt(tile: number[] | number[][] | Phaser.Tilemaps.Tile[] | Phaser.Tilemaps.Tile[][], tileX: number, tileY: number, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then - * those will be used for randomly assigning new tile indexes. If an array is not provided, the - * indexes found within the region (excluding -1) will be used for randomly assigning new tile - * indexes. This method only modifies tile indexes and does not change collision information. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param indexes An array of indexes to randomly draw from during randomization. - * @param layer The Tilemap Layer to act upon. - */ - function Randomize(tileX: number, tileY: number, width: number, height: number, indexes: number[], layer: Phaser.Tilemaps.LayerData): void; - - /** - * Removes the tile at the given tile coordinates in the specified layer and updates the layer's - * collision information. - * @param tileX The x coordinate. - * @param tileY The y coordinate. - * @param replaceWithNull If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. - * @param recalculateFaces `true` if the faces data should be recalculated. - * @param layer The Tilemap Layer to act upon. - */ - function RemoveTileAt(tileX: number, tileY: number, replaceWithNull: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; - - /** - * Removes the tile at the given world coordinates in the specified layer and updates the layer's - * collision information. - * @param worldX The x coordinate, in pixels. - * @param worldY The y coordinate, in pixels. - * @param replaceWithNull If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. - * @param recalculateFaces `true` if the faces data should be recalculated. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function RemoveTileAtWorldXY(worldX: number, worldY: number, replaceWithNull: boolean, recalculateFaces: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; - - /** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * @param graphics The target Graphics object to draw upon. - * @param styleConfig An object specifying the colors to use for the debug drawing. - * @param layer The Tilemap Layer to act upon. - */ - function RenderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig: Phaser.Types.Tilemaps.DebugStyleOptions, layer: Phaser.Tilemaps.LayerData): void; - - /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does - * not change collision information. - * @param findIndex The index of the tile to search for. - * @param newIndex The index of the tile to replace it with. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param layer The Tilemap Layer to act upon. - */ - function ReplaceByIndex(findIndex: number, newIndex: number, tileX: number, tileY: number, width: number, height: number, layer: Phaser.Tilemaps.LayerData): void; - - /** - * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. - * @param layer The Tilemap Layer to act upon. - * @param bounds An object containing the `left`, `right`, `top` and `bottom` bounds. - * @param renderOrder The rendering order constant. - * @param outputArray The array to store the Tile objects within. - */ - function RunCull(layer: Phaser.Tilemaps.LayerData, bounds: object, renderOrder: number, outputArray: any[]): Phaser.Tilemaps.Tile[]; - - /** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * @param indexes Either a single tile index, or an array of tile indexes. - * @param collides If true it will enable collision. If false it will clear collision. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. - * @param layer The Tilemap Layer to act upon. - * @param updateLayer If true, updates the current tiles on the layer. Set to false if no tiles have been placed for significant performance boost. Default true. - */ - function SetCollision(indexes: number | any[], collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData, updateLayer?: boolean): void; - - /** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * @param start The first index of the tile to be set for collision. - * @param stop The last index of the tile to be set for collision. - * @param collides If true it will enable collision. If false it will clear collision. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. - * @param layer The Tilemap Layer to act upon. - * @param updateLayer If true, updates the current tiles on the layer. Set to false if no tiles have been placed for significant performance boost. Default true. - */ - function SetCollisionBetween(start: number, stop: number, collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData, updateLayer?: boolean): void; - - /** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). Tile indexes not currently in the layer are not affected. - * @param indexes An array of the tile indexes to not be counted for collision. - * @param collides If true it will enable collision. If false it will clear collision. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. - * @param layer The Tilemap Layer to act upon. - */ - function SetCollisionByExclusion(indexes: number[], collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; - - /** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * @param properties An object with tile properties and corresponding values that should be checked. - * @param collides If true it will enable collision. If false it will clear collision. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. - * @param layer The Tilemap Layer to act upon. - */ - function SetCollisionByProperty(properties: object, collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; - - /** - * Sets collision on the tiles within a layer by checking each tile's collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tile's collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * @param collides If true it will enable collision. If false it will clear collision. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. - * @param layer The Tilemap Layer to act upon. - */ - function SetCollisionFromCollisionGroup(collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; - - /** - * Internally used method to keep track of the tile indexes that collide within a layer. This - * updates LayerData.collideIndexes to either contain or not contain the given `tileIndex`. - * @param tileIndex The tile index to set the collision boolean for. - * @param collides Should the tile index collide or not? - * @param layer The Tilemap Layer to act upon. - */ - function SetLayerCollisionIndex(tileIndex: number, collides: boolean, layer: Phaser.Tilemaps.LayerData): void; - - /** - * Internally used method to set the colliding state of a tile. This does not recalculate - * interesting faces. - * @param tile The Tile to set the collision on. - * @param collides Should the tile index collide or not? Default true. - */ - function SetTileCollision(tile: Phaser.Tilemaps.Tile, collides?: boolean): void; - - /** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * @param indexes Either a single tile index, or an array of tile indexes to have a collision callback set for. - * @param callback The callback that will be invoked when the tile is collided with. - * @param callbackContext The context under which the callback is called. - * @param layer The Tilemap Layer to act upon. - */ - function SetTileIndexCallback(indexes: number | any[], callback: Function, callbackContext: object, layer: Phaser.Tilemaps.LayerData): void; - - /** - * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param callback The callback that will be invoked when the tile is collided with. - * @param callbackContext The context under which the callback is called. - * @param layer The Tilemap Layer to act upon. - */ - function SetTileLocationCallback(tileX: number, tileY: number, width: number, height: number, callback: Function, callbackContext: object, layer: Phaser.Tilemaps.LayerData): void; - - /** - * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given - * layer. It will only randomize the tiles in that area, so if they're all the same nothing will - * appear to have changed! This method only modifies tile indexes and does not change collision - * information. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param layer The Tilemap Layer to act upon. - */ - function Shuffle(tileX: number, tileY: number, width: number, height: number, layer: Phaser.Tilemaps.LayerData): void; - - /** - * Returns the bounds in the given layer that are within the camera's viewport. - * This is used internally by the cull tiles function. - * @param layer The Tilemap Layer to act upon. - * @param camera The Camera to run the cull check against. - */ - function StaggeredCullBounds(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera): object; - - /** - * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. - * @param layer The Tilemap Layer to act upon. - * @param camera The Camera to run the cull check against. - * @param outputArray An optional array to store the Tile objects within. - * @param renderOrder The rendering order constant. Default 0. - */ - function StaggeredCullTiles(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera, outputArray?: any[], renderOrder?: number): Phaser.Tilemaps.Tile[]; - - /** - * Converts from staggered tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function StaggeredTileToWorldXY(tileX: number, tileY: number, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; - - /** - * Converts from staggered tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layers position, scale and scroll. - * @param tileY The y coordinate, in tiles, not pixels. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function StaggeredTileToWorldY(tileY: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; - - /** - * Converts from world XY coordinates (pixels) to staggered tile XY coordinates (tile units), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param worldX The x coordinate to be converted, in pixels, not tiles. - * @param worldY The y coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. - * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function StaggeredWorldToTileXY(worldX: number, worldY: number, snapToFloor: boolean, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; - - /** - * Converts from world Y coordinates (pixels) to staggered tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. - * @param worldY The y coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function StaggeredWorldToTileY(worldY: number, snapToFloor: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; - - /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision - * information. - * @param tileA First tile index. - * @param tileB Second tile index. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param layer The Tilemap Layer to act upon. - */ - function SwapByIndex(tileA: number, tileB: number, tileX: number, tileY: number, width: number, height: number, layer: Phaser.Tilemaps.LayerData): void; - - /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layer's position, scale and scroll. - * @param tileX The x coordinate, in tiles, not pixels. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function TileToWorldX(tileX: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; - - /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function TileToWorldXY(tileX: number, tileY: number, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; - - /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layer's position, scale and scroll. - * @param tileY The y coordinate, in tiles, not pixels. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function TileToWorldY(tileY: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. New indexes are drawn from the given - * weightedIndexes array. An example weighted array: - * - * [ - * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 - * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 - * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 - * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 - * ] - * - * The probability of any index being choose is (the index's weight) / (sum of all weights). This - * method only modifies tile indexes and does not change collision information. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param weightedIndexes An array of objects to randomly draw from during - * randomization. They should be in the form: { index: 0, weight: 4 } or - * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. - * @param layer The Tilemap Layer to act upon. - */ - function WeightedRandomize(tileX: number, tileY: number, width: number, height: number, weightedIndexes: object[], layer: Phaser.Tilemaps.LayerData): void; - - /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layer's position, scale and scroll. - * @param worldX The x coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function WorldToTileX(worldX: number, snapToFloor: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; - - /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param worldX The x coordinate to be converted, in pixels, not tiles. - * @param worldY The y coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. - * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function WorldToTileXY(worldX: number, worldY: number, snapToFloor: boolean, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; - - /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layer's position, scale and scroll. - * @param worldY The y coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - */ - function WorldToTileY(worldY: number, snapToFloor: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; - - } - - /** - * Phaser Tilemap constants for orientation. - */ - enum Orientation { - /** - * Orthogonal Tilemap orientation constant. - */ - ORTHOGONAL, - /** - * Isometric Tilemap orientation constant. - */ - ISOMETRIC, - /** - * Staggered Tilemap orientation constant. - */ - STAGGERED, - /** - * Hexagonal Tilemap orientation constant. - */ - HEXAGONAL, - } - - /** - * Phaser Tilemap constants for orientation. - * - * To find out what each mode does please see [Phaser.Tilemaps.Orientation]{@link Phaser.Tilemaps.Orientation}. - */ - type OrientationType = Phaser.Tilemaps.Orientation; - namespace Formats { /** * CSV Map Type @@ -90589,513 +89809,6 @@ declare namespace Phaser { } - /** - * A class for representing data about about a layer in a map. Maps are parsed from CSV, Tiled, - * etc. into this format. Tilemap and TilemapLayer objects have a reference - * to this data and use it to look up and perform operations on tiles. - */ - class LayerData { - /** - * - * @param config The Layer Data configuration object. - */ - constructor(config?: Phaser.Types.Tilemaps.LayerDataConfig); - - /** - * The name of the layer, if specified in Tiled. - */ - name: string; - - /** - * The x offset of where to draw from the top left. - */ - x: number; - - /** - * The y offset of where to draw from the top left. - */ - y: number; - - /** - * The width of the layer in tiles. - */ - width: number; - - /** - * The height of the layer in tiles. - */ - height: number; - - /** - * The pixel width of the tiles. - */ - tileWidth: number; - - /** - * The pixel height of the tiles. - */ - tileHeight: number; - - /** - * The base tile width. - */ - baseTileWidth: number; - - /** - * The base tile height. - */ - baseTileHeight: number; - - /** - * The layers orientation, necessary to be able to determine a tiles pixelX and pixelY as well as the layers width and height. - */ - orientation: Phaser.Tilemaps.OrientationType; - - /** - * The width in pixels of the entire layer. - */ - widthInPixels: number; - - /** - * The height in pixels of the entire layer. - */ - heightInPixels: number; - - /** - * The alpha value of the layer. - */ - alpha: number; - - /** - * Is the layer visible or not? - */ - visible: boolean; - - /** - * Layer specific properties (can be specified in Tiled) - */ - properties: object[]; - - /** - * Tile ID index map. - */ - indexes: any[]; - - /** - * Tile Collision ID index map. - */ - collideIndexes: any[]; - - /** - * An array of callbacks. - */ - callbacks: any[]; - - /** - * An array of physics bodies. - */ - bodies: any[]; - - /** - * An array of the tile data indexes. - */ - data: Phaser.Tilemaps.Tile[][]; - - /** - * A reference to the Tilemap layer that owns this data. - */ - tilemapLayer: Phaser.Tilemaps.TilemapLayer; - - /** - * The length of the horizontal sides of the hexagon. - * Only used for hexagonal orientation Tilemaps. - */ - hexSideLength: number; - - } - - /** - * A class for representing data about a map. Maps are parsed from CSV, Tiled, etc. into this - * format. A Tilemap object get a copy of this data and then unpacks the needed properties into - * itself. - */ - class MapData { - /** - * - * @param config The Map configuration object. - */ - constructor(config?: Phaser.Types.Tilemaps.MapDataConfig); - - /** - * The key in the Phaser cache that corresponds to the loaded tilemap data. - */ - name: string; - - /** - * The width of the entire tilemap. - */ - width: number; - - /** - * The height of the entire tilemap. - */ - height: number; - - /** - * If the map is infinite or not. - */ - infinite: boolean; - - /** - * The width of the tiles. - */ - tileWidth: number; - - /** - * The height of the tiles. - */ - tileHeight: number; - - /** - * The width in pixels of the entire tilemap. - */ - widthInPixels: number; - - /** - * The height in pixels of the entire tilemap. - */ - heightInPixels: number; - - /** - * The format of the map data. - */ - format: number; - - /** - * The orientation of the map data (i.e. orthogonal, isometric, hexagonal), default 'orthogonal'. - */ - orientation: Phaser.Tilemaps.OrientationType; - - /** - * Determines the draw order of tilemap. Default is right-down - * - * 0, or 'right-down' - * 1, or 'left-down' - * 2, or 'right-up' - * 3, or 'left-up' - */ - renderOrder: string; - - /** - * The version of the map data (as specified in Tiled). - */ - version: string; - - /** - * Map specific properties (can be specified in Tiled) - */ - properties: object; - - /** - * An array with all the layers configured to the MapData. - */ - layers: Phaser.Tilemaps.LayerData[] | Phaser.Tilemaps.ObjectLayer; - - /** - * An array of Tiled Image Layers. - */ - images: any[]; - - /** - * An object of Tiled Object Layers. - */ - objects: object; - - /** - * An object of collision data. Must be created as physics object or will return undefined. - */ - collision: object; - - /** - * An array of Tilesets. - */ - tilesets: Phaser.Tilemaps.Tileset[]; - - /** - * The collection of images the map uses(specified in Tiled) - */ - imageCollections: any[]; - - /** - * An array of tile instances. - */ - tiles: any[]; - - /** - * The length of the horizontal sides of the hexagon. - * Only used for hexagonal orientation Tilemaps. - */ - hexSideLength: number; - - } - - /** - * A class for representing a Tiled object layer in a map. This mirrors the structure of a Tiled - * object layer, except: - * - "x" & "y" properties are ignored since these cannot be changed in Tiled. - * - "offsetx" & "offsety" are applied to the individual object coordinates directly, so they - * are ignored as well. - * - "draworder" is ignored. - */ - class ObjectLayer { - /** - * - * @param config The data for the layer from the Tiled JSON object. - */ - constructor(config?: Phaser.Types.Tilemaps.ObjectLayerConfig); - - /** - * The name of the Object Layer. - */ - name: string; - - /** - * The opacity of the layer, between 0 and 1. - */ - opacity: number; - - /** - * The custom properties defined on the Object Layer, keyed by their name. - */ - properties: object; - - /** - * The type of each custom property defined on the Object Layer, keyed by its name. - */ - propertyTypes: object; - - /** - * The type of the layer, which should be `objectgroup`. - */ - type: string; - - /** - * Whether the layer is shown (`true`) or hidden (`false`). - */ - visible: boolean; - - /** - * An array of all objects on this Object Layer. - * - * Each Tiled object corresponds to a JavaScript object in this array. It has an `id` (unique), - * `name` (as assigned in Tiled), `type` (as assigned in Tiled), `rotation` (in clockwise degrees), - * `properties` (if any), `visible` state (`true` if visible, `false` otherwise), - * `x` and `y` coordinates (in pixels, relative to the tilemap), and a `width` and `height` (in pixels). - * - * An object tile has a `gid` property (GID of the represented tile), a `flippedHorizontal` property, - * a `flippedVertical` property, and `flippedAntiDiagonal` property. - * The {@link http://docs.mapeditor.org/en/latest/reference/tmx-map-format/|Tiled documentation} contains - * information on flipping and rotation. - * - * Polylines have a `polyline` property, which is an array of objects corresponding to points, - * where each point has an `x` property and a `y` property. Polygons have an identically structured - * array in their `polygon` property. Text objects have a `text` property with the text's properties. - * - * Rectangles and ellipses have a `rectangle` or `ellipse` property set to `true`. - */ - objects: Phaser.Types.Tilemaps.TiledObject[]; - - } - - namespace Parsers { - /** - * Get the Tilemap orientation from the given string. - * @param orientation The orientation type as a string. - */ - function FromOrientationString(orientation?: string): Phaser.Tilemaps.OrientationType; - - namespace Impact { - /** - * Parses all tilemap layers in an Impact JSON object into new LayerData objects. - * @param json The Impact JSON object. - * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map - * data are handled (see {@link Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled}). - */ - function ParseTileLayers(json: object, insertNull: boolean): Phaser.Tilemaps.LayerData[]; - - /** - * Tilesets and Image Collections - * @param json The Impact JSON data. - */ - function ParseTilesets(json: object): any[]; - - /** - * Parses a Weltmeister JSON object into a new MapData object. - * @param name The name of the tilemap, used to set the name on the MapData. - * @param json The Weltmeister JSON object. - * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - */ - function ParseWeltmeister(name: string, json: object, insertNull: boolean): Phaser.Tilemaps.MapData; - - } - - /** - * Parses raw data of a given Tilemap format into a new MapData object. If no recognized data format - * is found, returns `null`. When loading from CSV or a 2D array, you should specify the tileWidth & - * tileHeight. When parsing from a map from Tiled, the tileWidth & tileHeight will be pulled from - * the map data. - * @param name The name of the tilemap, used to set the name on the MapData. - * @param mapFormat See ../Formats.js. - * @param data 2D array, CSV string or Tiled JSON object. - * @param tileWidth The width of a tile in pixels. Required for 2D array and CSV, but - * ignored for Tiled JSON. - * @param tileHeight The height of a tile in pixels. Required for 2D array and CSV, but - * ignored for Tiled JSON. - * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - */ - function Parse(name: string, mapFormat: number, data: number[][] | string | object, tileWidth: number, tileHeight: number, insertNull: boolean): Phaser.Tilemaps.MapData; - - /** - * Parses a 2D array of tile indexes into a new MapData object with a single layer. - * @param name The name of the tilemap, used to set the name on the MapData. - * @param data 2D array, CSV string or Tiled JSON object. - * @param tileWidth The width of a tile in pixels. - * @param tileHeight The height of a tile in pixels. - * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - */ - function Parse2DArray(name: string, data: number[][], tileWidth: number, tileHeight: number, insertNull: boolean): Phaser.Tilemaps.MapData; - - /** - * Parses a CSV string of tile indexes into a new MapData object with a single layer. - * @param name The name of the tilemap, used to set the name on the MapData. - * @param data CSV string of tile indexes. - * @param tileWidth The width of a tile in pixels. - * @param tileHeight The height of a tile in pixels. - * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - */ - function ParseCSV(name: string, data: string, tileWidth: number, tileHeight: number, insertNull: boolean): Phaser.Tilemaps.MapData; - - namespace Tiled { - /** - * Copy properties from tileset to tiles. - * @param mapData The Map Data object. - */ - function AssignTileProperties(mapData: Phaser.Tilemaps.MapData): void; - - /** - * Decode base-64 encoded data, for example as exported by Tiled. - * @param data Base-64 encoded data to decode. - */ - function Base64Decode(data: object): any[]; - - /** - * Master list of tiles -> x, y, index in tileset. - * @param mapData The Map Data object. - */ - function BuildTilesetIndex(mapData: Phaser.Tilemaps.MapData): any[]; - - /** - * Parse a Tiled group layer and create a state object for inheriting. - * @param json The Tiled JSON object. - * @param currentl The current group layer from the Tiled JSON file. - * @param parentstate The state of the parent group (if any). - */ - function CreateGroupLayer(json: object, currentl?: object, parentstate?: object): object; - - /** - * See Tiled documentation on tile flipping: - * http://docs.mapeditor.org/en/latest/reference/tmx-map-format/ - * @param gid A Tiled GID. - */ - function ParseGID(gid: number): Phaser.Types.Tilemaps.GIDData; - - /** - * Parses a Tiled JSON object into an array of objects with details about the image layers. - * @param json The Tiled JSON object. - */ - function ParseImageLayers(json: object): any[]; - - /** - * Parses a Tiled JSON object into a new MapData object. - * @param name The name of the tilemap, used to set the name on the MapData. - * @param json The Tiled JSON object. - * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - */ - function ParseJSONTiled(name: string, json: object, insertNull: boolean): Phaser.Tilemaps.MapData; - - /** - * Convert a Tiled object to an internal parsed object normalising and copying properties over, while applying optional x and y offsets. The parsed object will always have the properties `id`, `name`, `type`, `rotation`, `properties`, `visible`, `x`, `y`, `width` and `height`. Other properties will be added according to the object type (such as text, polyline, gid etc.) - * @param tiledObject Tiled object to convert to an internal parsed object normalising and copying properties over. - * @param offsetX Optional additional offset to apply to the object's x property. Defaults to 0. Default 0. - * @param offsetY Optional additional offset to apply to the object's y property. Defaults to 0. Default 0. - */ - function ParseObject(tiledObject: object, offsetX?: number, offsetY?: number): object; - - /** - * Parses a Tiled JSON object into an array of ObjectLayer objects. - * @param json The Tiled JSON object. - */ - function ParseObjectLayers(json: object): any[]; - - /** - * Parses all tilemap layers in a Tiled JSON object into new LayerData objects. - * @param json The Tiled JSON object. - * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map - * data are handled (see {@link Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled}). - */ - function ParseTileLayers(json: object, insertNull: boolean): Phaser.Tilemaps.LayerData[]; - - /** - * Tilesets and Image Collections. - * @param json The Tiled JSON data. - */ - function ParseTilesets(json: object): object; - - /** - * Parses out the Wangset information from Tiled 1.1.5+ map data, if present. - * - * Since a given tile can be in more than one wangset, the resulting properties - * are nested. `tile.data.wangid[someWangsetName]` will return the array-based wang id in - * this implementation. - * - * Note that we're not guaranteed that there will be any 'normal' tiles if the only - * thing in the tilset are wangtile definitions, so this has to be parsed separately. - * - * See https://doc.mapeditor.org/en/latest/manual/using-wang-tiles/ for more information. - * @param wangsets The array of wangset objects (parsed from JSON) - * @param datas The field into which to put wangset data from Tiled. - */ - function ParseWangsets(wangsets: object[], datas: object): object; - - } - - } - /** * Create a Tilemap from the given key or data. If neither is given, make a blank Tilemap. When * loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing from @@ -94215,6 +92928,1306 @@ declare namespace Phaser { } + namespace Components { + /** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * @param tileX The x coordinate. + * @param tileY The y coordinate. + * @param layer The Tilemap Layer to act upon. + */ + function CalculateFacesAt(tileX: number, tileY: number, layer: Phaser.Tilemaps.LayerData): void; + + /** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param layer The Tilemap Layer to act upon. + */ + function CalculateFacesWithin(tileX: number, tileY: number, width: number, height: number, layer: Phaser.Tilemaps.LayerData): void; + + /** + * Checks if the given tile coordinate is within the isometric layer bounds, or not. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param layer The Tilemap Layer to check against. + * @param camera The Camera to run the cull check against. + */ + function CheckIsoBounds(tileX: number, tileY: number, layer: Phaser.Tilemaps.LayerData, camera?: Phaser.Cameras.Scene2D.Camera): boolean; + + /** + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties & recalculates collision + * information in the destination region. + * @param srcTileX The x coordinate of the area to copy from, in tiles, not pixels. + * @param srcTileY The y coordinate of the area to copy from, in tiles, not pixels. + * @param width The width of the area to copy, in tiles, not pixels. + * @param height The height of the area to copy, in tiles, not pixels. + * @param destTileX The x coordinate of the area to copy to, in tiles, not pixels. + * @param destTileY The y coordinate of the area to copy to, in tiles, not pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. + * @param layer The Tilemap Layer to act upon. + */ + function Copy(srcTileX: number, srcTileY: number, width: number, height: number, destTileX: number, destTileY: number, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; + + /** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * @param indexes The tile index, or array of indexes, to create Sprites from. + * @param replacements The tile index, or array of indexes, to change a converted tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a one-to-one mapping with the indexes array. + * @param spriteConfig The config object to pass into the Sprite creator (i.e. scene.make.sprite). + * @param scene The Scene to create the Sprites within. + * @param camera The Camera to use when determining the world XY + * @param layer The Tilemap Layer to act upon. + */ + function CreateFromTiles(indexes: number | number[], replacements: number | number[], spriteConfig: Phaser.Types.GameObjects.Sprite.SpriteConfig, scene: Phaser.Scene, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.GameObjects.Sprite[]; + + /** + * Returns the bounds in the given orthogonal layer that are within the cameras viewport. + * This is used internally by the cull tiles function. + * @param layer The Tilemap Layer to act upon. + * @param camera The Camera to run the cull check against. + */ + function CullBounds(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera): Phaser.Geom.Rectangle; + + /** + * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. + * @param layer The Tilemap Layer to act upon. + * @param camera The Camera to run the cull check against. + * @param outputArray An optional array to store the Tile objects within. + * @param renderOrder The rendering order constant. Default 0. + */ + function CullTiles(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera, outputArray?: any[], renderOrder?: number): Phaser.Tilemaps.Tile[]; + + /** + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. + * @param index The tile index to fill the area with. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param recalculateFaces `true` if the faces data should be recalculated. + * @param layer The tile layer to use. If not given the current layer is used. + */ + function Fill(index: number, tileX: number, tileY: number, width: number, height: number, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * @param callback The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param context The context under which the callback should be run. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param layer The Tilemap Layer to act upon. + */ + function FilterTiles(callback: Function, context: object, tileX: number, tileY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; + + /** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * @param index The tile index value to search for. + * @param skip The number of times to skip a matching tile before returning. + * @param reverse If true it will scan the layer in reverse, starting at the bottom-right. Otherwise it scans from the top-left. + * @param layer The Tilemap Layer to act upon. + */ + function FindByIndex(index: number, skip: number, reverse: boolean, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + + /** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param context The context under which the callback should be run. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param layer The Tilemap Layer to act upon. + */ + function FindTile(callback: FindTileCallback, context: object, tileX: number, tileY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param context The context under which the callback should be run. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param layer The Tilemap Layer to act upon. + */ + function ForEachTile(callback: EachTileCallback, context: object, tileX: number, tileY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, layer: Phaser.Tilemaps.LayerData): void; + + /** + * Gets the correct function to use to cull tiles, based on the map orientation. + * @param orientation The Tilemap orientation constant. + */ + function GetCullTilesFunction(orientation: number): Function; + + /** + * Gets a tile at the given tile coordinates from the given layer. + * @param tileX X position to get the tile from (given in tile units, not pixels). + * @param tileY Y position to get the tile from (given in tile units, not pixels). + * @param nonNull If true getTile won't return null for empty tiles, but a Tile object with an index of -1. + * @param layer The Tilemap Layer to act upon. + */ + function GetTileAt(tileX: number, tileY: number, nonNull: boolean, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + + /** + * Gets a tile at the given world coordinates from the given layer. + * @param worldX X position to get the tile from (given in pixels) + * @param worldY Y position to get the tile from (given in pixels) + * @param nonNull If true, function won't return null for empty tiles, but a Tile object with an index of -1. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function GetTileAtWorldXY(worldX: number, worldY: number, nonNull: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + + /** + * Gets the correct function to use to translate tiles, based on the map orientation. + * @param orientation The Tilemap orientation constant. + */ + function GetTileToWorldXFunction(orientation: number): Function; + + /** + * Gets the correct function to use to translate tiles, based on the map orientation. + * @param orientation The Tilemap orientation constant. + */ + function GetTileToWorldXYFunction(orientation: number): Function; + + /** + * Gets the correct function to use to translate tiles, based on the map orientation. + * @param orientation The Tilemap orientation constant. + */ + function GetTileToWorldYFunction(orientation: number): Function; + + /** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param layer The Tilemap Layer to act upon. + */ + function GetTilesWithin(tileX: number, tileY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; + + /** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * @param shape A shape in world (pixel) coordinates + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function GetTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; + + /** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * @param worldX The world x coordinate for the top-left of the area. + * @param worldY The world y coordinate for the top-left of the area. + * @param width The width of the area. + * @param height The height of the area. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param camera The Camera to use when factoring in which tiles to return. + * @param layer The Tilemap Layer to act upon. + */ + function GetTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; + + /** + * Gets the correct function to use to translate tiles, based on the map orientation. + * @param orientation The Tilemap orientation constant. + */ + function GetWorldToTileXFunction(orientation: number): Function; + + /** + * Gets the correct function to use to translate tiles, based on the map orientation. + * @param orientation The Tilemap orientation constant. + */ + function GetWorldToTileXYFunction(orientation: number): Function; + + /** + * Gets the correct function to use to translate tiles, based on the map orientation. + * @param orientation The Tilemap orientation constant. + */ + function GetWorldToTileYFunction(orientation: number): Function; + + /** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * @param tileX X position to get the tile from (given in tile units, not pixels). + * @param tileY Y position to get the tile from (given in tile units, not pixels). + * @param layer The Tilemap Layer to act upon. + */ + function HasTileAt(tileX: number, tileY: number, layer: Phaser.Tilemaps.LayerData): boolean; + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * @param worldX The X coordinate of the world position. + * @param worldY The Y coordinate of the world position. + * @param camera The Camera to use when factoring in which tiles to return. + * @param layer The Tilemap Layer to act upon. + */ + function HasTileAtWorldXY(worldX: number, worldY: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): boolean; + + /** + * Returns the bounds in the given layer that are within the camera's viewport. + * This is used internally by the cull tiles function. + * @param layer The Tilemap Layer to act upon. + * @param camera The Camera to run the cull check against. + */ + function HexagonalCullBounds(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera): object; + + /** + * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. + * @param layer The Tilemap Layer to act upon. + * @param camera The Camera to run the cull check against. + * @param outputArray An optional array to store the Tile objects within. + * @param renderOrder The rendering order constant. Default 0. + */ + function HexagonalCullTiles(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera, outputArray?: any[], renderOrder?: number): Phaser.Tilemaps.Tile[]; + + /** + * Converts from hexagonal tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function HexagonalTileToWorldXY(tileX: number, tileY: number, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; + + /** + * Converts from hexagonal tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layer's position, scale and scroll. + * @param tileY The y coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function HexagonalTileToWorldY(tileY: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; + + /** + * Converts from world XY coordinates (pixels) to hexagonal tile XY coordinates (tile units), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param worldX The x coordinate to be converted, in pixels, not tiles. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinates down to the nearest integer. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function HexagonalWorldToTileXY(worldX: number, worldY: number, snapToFloor: boolean, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; + + /** + * Converts from world Y coordinates (pixels) to hexagonal tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function HexagonalWorldToTileY(worldY: number, snapToFloor: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; + + /** + * Checks if the given tile coordinates are within the bounds of the layer. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param layer The Tilemap Layer to act upon. + */ + function IsInLayerBounds(tileX: number, tileY: number, layer: Phaser.Tilemaps.LayerData): boolean; + + /** + * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. + * @param layer The Tilemap Layer to act upon. + * @param camera The Camera to run the cull check against. + * @param outputArray An optional array to store the Tile objects within. + * @param renderOrder The rendering order constant. Default 0. + */ + function IsometricCullTiles(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera, outputArray?: any[], renderOrder?: number): Phaser.Tilemaps.Tile[]; + + /** + * Converts from isometric tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function IsometricTileToWorldXY(tileX: number, tileY: number, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; + + /** + * Converts from world XY coordinates (pixels) to isometric tile XY coordinates (tile units), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param worldX The x coordinate to be converted, in pixels, not tiles. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function IsometricWorldToTileXY(worldX: number, worldY: number, snapToFloor: boolean, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; + + /** + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. + * @param tile The index of this tile to set or a Tile object. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. + * @param layer The Tilemap Layer to act upon. + */ + function PutTileAt(tile: number | Phaser.Tilemaps.Tile, tileX: number, tileY: number, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + + /** + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * @param tile The index of this tile to set or a Tile object. + * @param worldX The x coordinate, in pixels. + * @param worldY The y coordinate, in pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function PutTileAtWorldXY(tile: number | Phaser.Tilemaps.Tile, worldX: number, worldY: number, recalculateFaces: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + + /** + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * @param tile A row (array) or grid (2D array) of Tiles or tile indexes to place. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. + * @param layer The Tilemap Layer to act upon. + */ + function PutTilesAt(tile: number[] | number[][] | Phaser.Tilemaps.Tile[] | Phaser.Tilemaps.Tile[][], tileX: number, tileY: number, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param indexes An array of indexes to randomly draw from during randomization. + * @param layer The Tilemap Layer to act upon. + */ + function Randomize(tileX: number, tileY: number, width: number, height: number, indexes: number[], layer: Phaser.Tilemaps.LayerData): void; + + /** + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. + * @param tileX The x coordinate. + * @param tileY The y coordinate. + * @param replaceWithNull If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param recalculateFaces `true` if the faces data should be recalculated. + * @param layer The Tilemap Layer to act upon. + */ + function RemoveTileAt(tileX: number, tileY: number, replaceWithNull: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + + /** + * Removes the tile at the given world coordinates in the specified layer and updates the layer's + * collision information. + * @param worldX The x coordinate, in pixels. + * @param worldY The y coordinate, in pixels. + * @param replaceWithNull If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param recalculateFaces `true` if the faces data should be recalculated. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function RemoveTileAtWorldXY(worldX: number, worldY: number, replaceWithNull: boolean, recalculateFaces: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + + /** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * @param graphics The target Graphics object to draw upon. + * @param styleConfig An object specifying the colors to use for the debug drawing. + * @param layer The Tilemap Layer to act upon. + */ + function RenderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig: Phaser.Types.Tilemaps.DebugStyleOptions, layer: Phaser.Tilemaps.LayerData): void; + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. + * @param findIndex The index of the tile to search for. + * @param newIndex The index of the tile to replace it with. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param layer The Tilemap Layer to act upon. + */ + function ReplaceByIndex(findIndex: number, newIndex: number, tileX: number, tileY: number, width: number, height: number, layer: Phaser.Tilemaps.LayerData): void; + + /** + * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. + * @param layer The Tilemap Layer to act upon. + * @param bounds An object containing the `left`, `right`, `top` and `bottom` bounds. + * @param renderOrder The rendering order constant. + * @param outputArray The array to store the Tile objects within. + */ + function RunCull(layer: Phaser.Tilemaps.LayerData, bounds: object, renderOrder: number, outputArray: any[]): Phaser.Tilemaps.Tile[]; + + /** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * @param indexes Either a single tile index, or an array of tile indexes. + * @param collides If true it will enable collision. If false it will clear collision. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. + * @param layer The Tilemap Layer to act upon. + * @param updateLayer If true, updates the current tiles on the layer. Set to false if no tiles have been placed for significant performance boost. Default true. + */ + function SetCollision(indexes: number | any[], collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData, updateLayer?: boolean): void; + + /** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * @param start The first index of the tile to be set for collision. + * @param stop The last index of the tile to be set for collision. + * @param collides If true it will enable collision. If false it will clear collision. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. + * @param layer The Tilemap Layer to act upon. + * @param updateLayer If true, updates the current tiles on the layer. Set to false if no tiles have been placed for significant performance boost. Default true. + */ + function SetCollisionBetween(start: number, stop: number, collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData, updateLayer?: boolean): void; + + /** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). Tile indexes not currently in the layer are not affected. + * @param indexes An array of the tile indexes to not be counted for collision. + * @param collides If true it will enable collision. If false it will clear collision. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. + * @param layer The Tilemap Layer to act upon. + */ + function SetCollisionByExclusion(indexes: number[], collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; + + /** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * @param properties An object with tile properties and corresponding values that should be checked. + * @param collides If true it will enable collision. If false it will clear collision. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. + * @param layer The Tilemap Layer to act upon. + */ + function SetCollisionByProperty(properties: object, collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; + + /** + * Sets collision on the tiles within a layer by checking each tile's collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tile's collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * @param collides If true it will enable collision. If false it will clear collision. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. + * @param layer The Tilemap Layer to act upon. + */ + function SetCollisionFromCollisionGroup(collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; + + /** + * Internally used method to keep track of the tile indexes that collide within a layer. This + * updates LayerData.collideIndexes to either contain or not contain the given `tileIndex`. + * @param tileIndex The tile index to set the collision boolean for. + * @param collides Should the tile index collide or not? + * @param layer The Tilemap Layer to act upon. + */ + function SetLayerCollisionIndex(tileIndex: number, collides: boolean, layer: Phaser.Tilemaps.LayerData): void; + + /** + * Internally used method to set the colliding state of a tile. This does not recalculate + * interesting faces. + * @param tile The Tile to set the collision on. + * @param collides Should the tile index collide or not? Default true. + */ + function SetTileCollision(tile: Phaser.Tilemaps.Tile, collides?: boolean): void; + + /** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * @param indexes Either a single tile index, or an array of tile indexes to have a collision callback set for. + * @param callback The callback that will be invoked when the tile is collided with. + * @param callbackContext The context under which the callback is called. + * @param layer The Tilemap Layer to act upon. + */ + function SetTileIndexCallback(indexes: number | any[], callback: Function, callbackContext: object, layer: Phaser.Tilemaps.LayerData): void; + + /** + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param callback The callback that will be invoked when the tile is collided with. + * @param callbackContext The context under which the callback is called. + * @param layer The Tilemap Layer to act upon. + */ + function SetTileLocationCallback(tileX: number, tileY: number, width: number, height: number, callback: Function, callbackContext: object, layer: Phaser.Tilemaps.LayerData): void; + + /** + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param layer The Tilemap Layer to act upon. + */ + function Shuffle(tileX: number, tileY: number, width: number, height: number, layer: Phaser.Tilemaps.LayerData): void; + + /** + * Returns the bounds in the given layer that are within the camera's viewport. + * This is used internally by the cull tiles function. + * @param layer The Tilemap Layer to act upon. + * @param camera The Camera to run the cull check against. + */ + function StaggeredCullBounds(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera): object; + + /** + * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. + * @param layer The Tilemap Layer to act upon. + * @param camera The Camera to run the cull check against. + * @param outputArray An optional array to store the Tile objects within. + * @param renderOrder The rendering order constant. Default 0. + */ + function StaggeredCullTiles(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera, outputArray?: any[], renderOrder?: number): Phaser.Tilemaps.Tile[]; + + /** + * Converts from staggered tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function StaggeredTileToWorldXY(tileX: number, tileY: number, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; + + /** + * Converts from staggered tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * @param tileY The y coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function StaggeredTileToWorldY(tileY: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; + + /** + * Converts from world XY coordinates (pixels) to staggered tile XY coordinates (tile units), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param worldX The x coordinate to be converted, in pixels, not tiles. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function StaggeredWorldToTileXY(worldX: number, worldY: number, snapToFloor: boolean, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; + + /** + * Converts from world Y coordinates (pixels) to staggered tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function StaggeredWorldToTileY(worldY: number, snapToFloor: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * @param tileA First tile index. + * @param tileB Second tile index. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param layer The Tilemap Layer to act upon. + */ + function SwapByIndex(tileA: number, tileB: number, tileX: number, tileY: number, width: number, height: number, layer: Phaser.Tilemaps.LayerData): void; + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layer's position, scale and scroll. + * @param tileX The x coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function TileToWorldX(tileX: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function TileToWorldXY(tileX: number, tileY: number, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; + + /** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layer's position, scale and scroll. + * @param tileY The y coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function TileToWorldY(tileY: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: + * + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being choose is (the index's weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param weightedIndexes An array of objects to randomly draw from during + * randomization. They should be in the form: { index: 0, weight: 4 } or + * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * @param layer The Tilemap Layer to act upon. + */ + function WeightedRandomize(tileX: number, tileY: number, width: number, height: number, weightedIndexes: object[], layer: Phaser.Tilemaps.LayerData): void; + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layer's position, scale and scroll. + * @param worldX The x coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function WorldToTileX(worldX: number, snapToFloor: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param worldX The x coordinate to be converted, in pixels, not tiles. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function WorldToTileXY(worldX: number, worldY: number, snapToFloor: boolean, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; + + /** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layer's position, scale and scroll. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + */ + function WorldToTileY(worldY: number, snapToFloor: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; + + } + + /** + * Phaser Tilemap constants for orientation. + */ + enum Orientation { + /** + * Orthogonal Tilemap orientation constant. + */ + ORTHOGONAL, + /** + * Isometric Tilemap orientation constant. + */ + ISOMETRIC, + /** + * Staggered Tilemap orientation constant. + */ + STAGGERED, + /** + * Hexagonal Tilemap orientation constant. + */ + HEXAGONAL, + } + + /** + * Phaser Tilemap constants for orientation. + * + * To find out what each mode does please see [Phaser.Tilemaps.Orientation]{@link Phaser.Tilemaps.Orientation}. + */ + type OrientationType = Phaser.Tilemaps.Orientation; + + /** + * A class for representing data about about a layer in a map. Maps are parsed from CSV, Tiled, + * etc. into this format. Tilemap and TilemapLayer objects have a reference + * to this data and use it to look up and perform operations on tiles. + */ + class LayerData { + /** + * + * @param config The Layer Data configuration object. + */ + constructor(config?: Phaser.Types.Tilemaps.LayerDataConfig); + + /** + * The name of the layer, if specified in Tiled. + */ + name: string; + + /** + * The x offset of where to draw from the top left. + */ + x: number; + + /** + * The y offset of where to draw from the top left. + */ + y: number; + + /** + * The width of the layer in tiles. + */ + width: number; + + /** + * The height of the layer in tiles. + */ + height: number; + + /** + * The pixel width of the tiles. + */ + tileWidth: number; + + /** + * The pixel height of the tiles. + */ + tileHeight: number; + + /** + * The base tile width. + */ + baseTileWidth: number; + + /** + * The base tile height. + */ + baseTileHeight: number; + + /** + * The layers orientation, necessary to be able to determine a tiles pixelX and pixelY as well as the layers width and height. + */ + orientation: Phaser.Tilemaps.OrientationType; + + /** + * The width in pixels of the entire layer. + */ + widthInPixels: number; + + /** + * The height in pixels of the entire layer. + */ + heightInPixels: number; + + /** + * The alpha value of the layer. + */ + alpha: number; + + /** + * Is the layer visible or not? + */ + visible: boolean; + + /** + * Layer specific properties (can be specified in Tiled) + */ + properties: object[]; + + /** + * Tile ID index map. + */ + indexes: any[]; + + /** + * Tile Collision ID index map. + */ + collideIndexes: any[]; + + /** + * An array of callbacks. + */ + callbacks: any[]; + + /** + * An array of physics bodies. + */ + bodies: any[]; + + /** + * An array of the tile data indexes. + */ + data: Phaser.Tilemaps.Tile[][]; + + /** + * A reference to the Tilemap layer that owns this data. + */ + tilemapLayer: Phaser.Tilemaps.TilemapLayer; + + /** + * The length of the horizontal sides of the hexagon. + * Only used for hexagonal orientation Tilemaps. + */ + hexSideLength: number; + + } + + /** + * A class for representing data about a map. Maps are parsed from CSV, Tiled, etc. into this + * format. A Tilemap object get a copy of this data and then unpacks the needed properties into + * itself. + */ + class MapData { + /** + * + * @param config The Map configuration object. + */ + constructor(config?: Phaser.Types.Tilemaps.MapDataConfig); + + /** + * The key in the Phaser cache that corresponds to the loaded tilemap data. + */ + name: string; + + /** + * The width of the entire tilemap. + */ + width: number; + + /** + * The height of the entire tilemap. + */ + height: number; + + /** + * If the map is infinite or not. + */ + infinite: boolean; + + /** + * The width of the tiles. + */ + tileWidth: number; + + /** + * The height of the tiles. + */ + tileHeight: number; + + /** + * The width in pixels of the entire tilemap. + */ + widthInPixels: number; + + /** + * The height in pixels of the entire tilemap. + */ + heightInPixels: number; + + /** + * The format of the map data. + */ + format: number; + + /** + * The orientation of the map data (i.e. orthogonal, isometric, hexagonal), default 'orthogonal'. + */ + orientation: Phaser.Tilemaps.OrientationType; + + /** + * Determines the draw order of tilemap. Default is right-down + * + * 0, or 'right-down' + * 1, or 'left-down' + * 2, or 'right-up' + * 3, or 'left-up' + */ + renderOrder: string; + + /** + * The version of the map data (as specified in Tiled). + */ + version: string; + + /** + * Map specific properties (can be specified in Tiled) + */ + properties: object; + + /** + * An array with all the layers configured to the MapData. + */ + layers: Phaser.Tilemaps.LayerData[] | Phaser.Tilemaps.ObjectLayer; + + /** + * An array of Tiled Image Layers. + */ + images: any[]; + + /** + * An object of Tiled Object Layers. + */ + objects: object; + + /** + * An object of collision data. Must be created as physics object or will return undefined. + */ + collision: object; + + /** + * An array of Tilesets. + */ + tilesets: Phaser.Tilemaps.Tileset[]; + + /** + * The collection of images the map uses(specified in Tiled) + */ + imageCollections: any[]; + + /** + * An array of tile instances. + */ + tiles: any[]; + + /** + * The length of the horizontal sides of the hexagon. + * Only used for hexagonal orientation Tilemaps. + */ + hexSideLength: number; + + } + + /** + * A class for representing a Tiled object layer in a map. This mirrors the structure of a Tiled + * object layer, except: + * - "x" & "y" properties are ignored since these cannot be changed in Tiled. + * - "offsetx" & "offsety" are applied to the individual object coordinates directly, so they + * are ignored as well. + * - "draworder" is ignored. + */ + class ObjectLayer { + /** + * + * @param config The data for the layer from the Tiled JSON object. + */ + constructor(config?: Phaser.Types.Tilemaps.ObjectLayerConfig); + + /** + * The name of the Object Layer. + */ + name: string; + + /** + * The opacity of the layer, between 0 and 1. + */ + opacity: number; + + /** + * The custom properties defined on the Object Layer, keyed by their name. + */ + properties: object; + + /** + * The type of each custom property defined on the Object Layer, keyed by its name. + */ + propertyTypes: object; + + /** + * The type of the layer, which should be `objectgroup`. + */ + type: string; + + /** + * Whether the layer is shown (`true`) or hidden (`false`). + */ + visible: boolean; + + /** + * An array of all objects on this Object Layer. + * + * Each Tiled object corresponds to a JavaScript object in this array. It has an `id` (unique), + * `name` (as assigned in Tiled), `type` (as assigned in Tiled), `rotation` (in clockwise degrees), + * `properties` (if any), `visible` state (`true` if visible, `false` otherwise), + * `x` and `y` coordinates (in pixels, relative to the tilemap), and a `width` and `height` (in pixels). + * + * An object tile has a `gid` property (GID of the represented tile), a `flippedHorizontal` property, + * a `flippedVertical` property, and `flippedAntiDiagonal` property. + * The {@link http://docs.mapeditor.org/en/latest/reference/tmx-map-format/|Tiled documentation} contains + * information on flipping and rotation. + * + * Polylines have a `polyline` property, which is an array of objects corresponding to points, + * where each point has an `x` property and a `y` property. Polygons have an identically structured + * array in their `polygon` property. Text objects have a `text` property with the text's properties. + * + * Rectangles and ellipses have a `rectangle` or `ellipse` property set to `true`. + */ + objects: Phaser.Types.Tilemaps.TiledObject[]; + + } + + namespace Parsers { + /** + * Get the Tilemap orientation from the given string. + * @param orientation The orientation type as a string. + */ + function FromOrientationString(orientation?: string): Phaser.Tilemaps.OrientationType; + + /** + * Parses raw data of a given Tilemap format into a new MapData object. If no recognized data format + * is found, returns `null`. When loading from CSV or a 2D array, you should specify the tileWidth & + * tileHeight. When parsing from a map from Tiled, the tileWidth & tileHeight will be pulled from + * the map data. + * @param name The name of the tilemap, used to set the name on the MapData. + * @param mapFormat See ../Formats.js. + * @param data 2D array, CSV string or Tiled JSON object. + * @param tileWidth The width of a tile in pixels. Required for 2D array and CSV, but + * ignored for Tiled JSON. + * @param tileHeight The height of a tile in pixels. Required for 2D array and CSV, but + * ignored for Tiled JSON. + * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + */ + function Parse(name: string, mapFormat: number, data: number[][] | string | object, tileWidth: number, tileHeight: number, insertNull: boolean): Phaser.Tilemaps.MapData; + + /** + * Parses a 2D array of tile indexes into a new MapData object with a single layer. + * @param name The name of the tilemap, used to set the name on the MapData. + * @param data 2D array, CSV string or Tiled JSON object. + * @param tileWidth The width of a tile in pixels. + * @param tileHeight The height of a tile in pixels. + * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + */ + function Parse2DArray(name: string, data: number[][], tileWidth: number, tileHeight: number, insertNull: boolean): Phaser.Tilemaps.MapData; + + /** + * Parses a CSV string of tile indexes into a new MapData object with a single layer. + * @param name The name of the tilemap, used to set the name on the MapData. + * @param data CSV string of tile indexes. + * @param tileWidth The width of a tile in pixels. + * @param tileHeight The height of a tile in pixels. + * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + */ + function ParseCSV(name: string, data: string, tileWidth: number, tileHeight: number, insertNull: boolean): Phaser.Tilemaps.MapData; + + namespace Impact { + /** + * Parses all tilemap layers in an Impact JSON object into new LayerData objects. + * @param json The Impact JSON object. + * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map + * data are handled (see {@link Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled}). + */ + function ParseTileLayers(json: object, insertNull: boolean): Phaser.Tilemaps.LayerData[]; + + /** + * Tilesets and Image Collections + * @param json The Impact JSON data. + */ + function ParseTilesets(json: object): any[]; + + /** + * Parses a Weltmeister JSON object into a new MapData object. + * @param name The name of the tilemap, used to set the name on the MapData. + * @param json The Weltmeister JSON object. + * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + */ + function ParseWeltmeister(name: string, json: object, insertNull: boolean): Phaser.Tilemaps.MapData; + + } + + namespace Tiled { + /** + * Copy properties from tileset to tiles. + * @param mapData The Map Data object. + */ + function AssignTileProperties(mapData: Phaser.Tilemaps.MapData): void; + + /** + * Decode base-64 encoded data, for example as exported by Tiled. + * @param data Base-64 encoded data to decode. + */ + function Base64Decode(data: object): any[]; + + /** + * Master list of tiles -> x, y, index in tileset. + * @param mapData The Map Data object. + */ + function BuildTilesetIndex(mapData: Phaser.Tilemaps.MapData): any[]; + + /** + * Parse a Tiled group layer and create a state object for inheriting. + * @param json The Tiled JSON object. + * @param currentl The current group layer from the Tiled JSON file. + * @param parentstate The state of the parent group (if any). + */ + function CreateGroupLayer(json: object, currentl?: object, parentstate?: object): object; + + /** + * See Tiled documentation on tile flipping: + * http://docs.mapeditor.org/en/latest/reference/tmx-map-format/ + * @param gid A Tiled GID. + */ + function ParseGID(gid: number): Phaser.Types.Tilemaps.GIDData; + + /** + * Parses a Tiled JSON object into an array of objects with details about the image layers. + * @param json The Tiled JSON object. + */ + function ParseImageLayers(json: object): any[]; + + /** + * Parses a Tiled JSON object into a new MapData object. + * @param name The name of the tilemap, used to set the name on the MapData. + * @param json The Tiled JSON object. + * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + */ + function ParseJSONTiled(name: string, json: object, insertNull: boolean): Phaser.Tilemaps.MapData; + + /** + * Convert a Tiled object to an internal parsed object normalising and copying properties over, while applying optional x and y offsets. The parsed object will always have the properties `id`, `name`, `type`, `rotation`, `properties`, `visible`, `x`, `y`, `width` and `height`. Other properties will be added according to the object type (such as text, polyline, gid etc.) + * @param tiledObject Tiled object to convert to an internal parsed object normalising and copying properties over. + * @param offsetX Optional additional offset to apply to the object's x property. Defaults to 0. Default 0. + * @param offsetY Optional additional offset to apply to the object's y property. Defaults to 0. Default 0. + */ + function ParseObject(tiledObject: object, offsetX?: number, offsetY?: number): object; + + /** + * Parses a Tiled JSON object into an array of ObjectLayer objects. + * @param json The Tiled JSON object. + */ + function ParseObjectLayers(json: object): any[]; + + /** + * Parses all tilemap layers in a Tiled JSON object into new LayerData objects. + * @param json The Tiled JSON object. + * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map + * data are handled (see {@link Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled}). + */ + function ParseTileLayers(json: object, insertNull: boolean): Phaser.Tilemaps.LayerData[]; + + /** + * Tilesets and Image Collections. + * @param json The Tiled JSON data. + */ + function ParseTilesets(json: object): object; + + /** + * Parses out the Wangset information from Tiled 1.1.5+ map data, if present. + * + * Since a given tile can be in more than one wangset, the resulting properties + * are nested. `tile.data.wangid[someWangsetName]` will return the array-based wang id in + * this implementation. + * + * Note that we're not guaranteed that there will be any 'normal' tiles if the only + * thing in the tilset are wangtile definitions, so this has to be parsed separately. + * + * See https://doc.mapeditor.org/en/latest/manual/using-wang-tiles/ for more information. + * @param wangsets The array of wangset objects (parsed from JSON) + * @param datas The field into which to put wangset data from Tiled. + */ + function ParseWangsets(wangsets: object[], datas: object): object; + + } + + } + /** * Orthogonal Tilemap orientation constant. */ @@ -94483,6 +94496,494 @@ declare namespace Phaser { } namespace Tweens { + /** + * A Timeline combines multiple Tweens into one. Its overall behavior is otherwise similar to a single Tween. + * + * The Timeline updates all of its Tweens simultaneously. Its methods allow you to easily build a sequence + * of Tweens (each one starting after the previous one) or run multiple Tweens at once during given parts of the Timeline. + */ + class Timeline extends Phaser.Events.EventEmitter { + /** + * + * @param manager The Tween Manager which owns this Timeline. + */ + constructor(manager: Phaser.Tweens.TweenManager); + + /** + * The Tween Manager which owns this Timeline. + */ + manager: Phaser.Tweens.TweenManager; + + /** + * A constant value which allows this Timeline to be easily identified as one. + */ + isTimeline: boolean; + + /** + * An array of Tween objects, each containing a unique property and target being tweened. + */ + data: any[]; + + /** + * The cached size of the data array. + */ + totalData: number; + + /** + * If true then duration, delay, etc values are all frame totals, rather than ms. + */ + useFrames: boolean; + + /** + * Scales the time applied to this Timeline. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * Value isn't used when calculating total duration of the Timeline, it's a run-time delta adjustment only. + */ + timeScale: number; + + /** + * Loop this Timeline? Can be -1 for an infinite loop, or an integer. + * When enabled it will play through ALL Tweens again (use Tween.repeat to loop a single tween) + */ + loop: number; + + /** + * Time in ms/frames before this Timeline loops. + */ + loopDelay: number; + + /** + * How many loops are left to run? + */ + loopCounter: number; + + /** + * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = true (as it never completes) + */ + completeDelay: number; + + /** + * Countdown timer value, as used by `loopDelay` and `completeDelay`. + */ + countdown: number; + + /** + * The current state of the Timeline. + */ + state: number; + + /** + * Does the Timeline start off paused? (if so it needs to be started with Timeline.play) + */ + paused: boolean; + + /** + * Elapsed time in ms/frames of this run through of the Timeline. + */ + elapsed: number; + + /** + * Total elapsed time in ms/frames of the entire Timeline, including looping. + */ + totalElapsed: number; + + /** + * Time in ms/frames for the whole Timeline to play through once, excluding loop amounts and loop delays. + */ + duration: number; + + /** + * Value between 0 and 1. The amount of progress through the Timeline, _excluding loops_. + */ + progress: number; + + /** + * Time in ms/frames for all Tweens in this Timeline to complete (including looping) + */ + totalDuration: number; + + /** + * Value between 0 and 1. The amount through the entire Timeline, including looping. + */ + totalProgress: number; + + /** + * An object containing the different Tween callback functions. + * + * You can either set these in the Tween config, or by calling the `Tween.setCallback` method. + * + * `onComplete` When the Timeline finishes playback fully or `Timeline.stop` is called. Never invoked if timeline is set to repeat infinitely. + * `onLoop` When a Timeline loops. + * `onStart` When the Timeline starts playing. + * `onUpdate` When a Timeline updates a child Tween. + * `onYoyo` When a Timeline starts a yoyo. + */ + callbacks: object; + + /** + * The context in which all callbacks are invoked. + */ + callbackScope: any; + + /** + * Internal method that will emit a Timeline based Event and invoke the given callback. + * @param event The Event to be dispatched. + * @param callback The callback to be invoked. Can be `null` or `undefined` to skip invocation. + */ + dispatchTimelineEvent(event: Phaser.Types.Tweens.Event, callback: Function): void; + + /** + * Sets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. + * A value of 0.5 runs 50% slower, and so on. + * + * The value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. + * @param value The time scale value to set. + */ + setTimeScale(value: number): this; + + /** + * Gets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. + * A value of 0.5 runs 50% slower, and so on. + */ + getTimeScale(): number; + + /** + * Check whether or not the Timeline is playing. + */ + isPlaying(): boolean; + + /** + * Creates a new Tween, based on the given Tween Config, and adds it to this Timeline. + * @param config The configuration object for the Tween. + */ + add(config: Phaser.Types.Tweens.TweenBuilderConfig | object): this; + + /** + * Adds an existing Tween to this Timeline. + * @param tween The Tween to be added to this Timeline. + */ + queue(tween: Phaser.Tweens.Tween): this; + + /** + * Checks whether a Tween has an offset value. + * @param tween The Tween to check. + */ + hasOffset(tween: Phaser.Tweens.Tween): boolean; + + /** + * Checks whether the offset value is a number or a directive that is relative to previous tweens. + * @param value The offset value to be evaluated. + */ + isOffsetAbsolute(value: number): boolean; + + /** + * Checks if the offset is a relative value rather than an absolute one. + * If the value is just a number, this returns false. + * @param value The offset value to be evaluated. + */ + isOffsetRelative(value: string): boolean; + + /** + * Parses the relative offset value, returning a positive or negative number. + * @param value The relative offset, in the format of '-=500', for example. The first character determines whether it will be a positive or negative number. Spacing matters here. + * @param base The value to use as the offset. + */ + getRelativeOffset(value: string, base: number): number; + + /** + * Calculates the total duration of the timeline. + * + * Computes all tween durations and returns the full duration of the timeline. + * + * The resulting number is stored in the timeline, not as a return value. + */ + calcDuration(): void; + + /** + * Initializes the timeline, which means all Tweens get their init() called, and the total duration will be computed. + * Returns a boolean indicating whether the timeline is auto-started or not. + */ + init(): boolean; + + /** + * Resets all of the timeline's tweens back to their initial states. + * The boolean parameter indicates whether tweens that are looping should reset as well, or not. + * @param resetFromLoop If `true`, resets all looping tweens to their initial values. + */ + resetTweens(resetFromLoop: boolean): void; + + /** + * Sets a callback for the Timeline. + * @param type The internal type of callback to set. + * @param callback Timeline allows multiple tweens to be linked together to create a streaming sequence. + * @param params The parameters to pass to the callback. + * @param scope The context scope of the callback. + */ + setCallback(type: string, callback: Function, params?: any[], scope?: object): this; + + /** + * Passed a Tween to the Tween Manager and requests it be made active. + * @param tween The tween object to make active. + */ + makeActive(tween: Phaser.Tweens.Tween): Phaser.Tweens.TweenManager; + + /** + * Starts playing the Timeline. + */ + play(): void; + + /** + * Updates the Timeline's `state` and fires callbacks and events. + */ + nextState(): void; + + /** + * Returns 'true' if this Timeline has finished and should be removed from the Tween Manager. + * Otherwise, returns false. + * @param timestamp The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update(timestamp: number, delta: number): boolean; + + /** + * Stops the Timeline immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. + */ + stop(): void; + + /** + * Pauses the Timeline, retaining its internal state. + * + * Calling this on a Timeline that is already paused has no effect and fires no event. + */ + pause(): this; + + /** + * Resumes a paused Timeline from where it was when it was paused. + * + * Calling this on a Timeline that isn't paused has no effect and fires no event. + */ + resume(): this; + + /** + * Checks if any of the Tweens in this Timeline as operating on the target object. + * + * Returns `false` if no Tweens operate on the target object. + * @param target The target to check all Tweens against. + */ + hasTarget(target: object): boolean; + + /** + * Stops all the Tweens in the Timeline immediately, whatever stage of progress they are at and flags + * them for removal by the TweenManager. + */ + destroy(): void; + + } + + /** + * The Tween Manager is a default Scene Plugin which controls and updates Tweens and Timelines. + */ + class TweenManager { + /** + * + * @param scene The Scene which owns this Tween Manager. + */ + constructor(scene: Phaser.Scene); + + /** + * The Scene which owns this Tween Manager. + */ + scene: Phaser.Scene; + + /** + * The Systems object of the Scene which owns this Tween Manager. + */ + systems: Phaser.Scenes.Systems; + + /** + * The time scale of the Tween Manager. + * + * This value scales the time delta between two frames, thus influencing the speed of time for all Tweens owned by this Tween Manager. + */ + timeScale: number; + + /** + * Create a Tween Timeline and return it, but do NOT add it to the active or pending Tween lists. + * @param config The configuration object for the Timeline and its Tweens. + */ + createTimeline(config?: Phaser.Types.Tweens.TimelineBuilderConfig): Phaser.Tweens.Timeline; + + /** + * Create a Tween Timeline and add it to the active Tween list. + * @param config The configuration object for the Timeline and its Tweens. + */ + timeline(config?: Phaser.Types.Tweens.TimelineBuilderConfig): Phaser.Tweens.Timeline; + + /** + * Create a Tween and return it, but do NOT add it to the active or pending Tween lists. + * @param config The configuration object for the Tween. + */ + create(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.Tween; + + /** + * Create a Tween and add it to the active Tween list. + * @param config The configuration object for the Tween. + */ + add(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.Tween; + + /** + * Add an existing tween into the active Tween list. + * @param tween The Tween to add. + */ + existing(tween: Phaser.Tweens.Tween): Phaser.Tweens.TweenManager; + + /** + * Create a Number Tween and add it to the active Tween list. + * @param config The configuration object for the Number Tween. + */ + addCounter(config: Phaser.Types.Tweens.NumberTweenBuilderConfig): Phaser.Tweens.Tween; + + /** + * Creates a Stagger function to be used by a Tween property. + * + * The stagger function will allow you to stagger changes to the value of the property across all targets of the tween. + * + * This is only worth using if the tween has multiple targets. + * + * The following will stagger the delay by 100ms across all targets of the tween, causing them to scale down to 0.2 + * over the duration specified: + * + * ```javascript + * this.tweens.add({ + * targets: [ ... ], + * scale: 0.2, + * ease: 'linear', + * duration: 1000, + * delay: this.tweens.stagger(100) + * }); + * ``` + * + * The following will stagger the delay by 500ms across all targets of the tween using a 10 x 6 grid, staggering + * from the center out, using a cubic ease. + * + * ```javascript + * this.tweens.add({ + * targets: [ ... ], + * scale: 0.2, + * ease: 'linear', + * duration: 1000, + * delay: this.tweens.stagger(500, { grid: [ 10, 6 ], from: 'center', ease: 'cubic.out' }) + * }); + * ``` + * @param value The amount to stagger by, or an array containing two elements representing the min and max values to stagger between. + * @param config The configuration object for the Stagger function. + */ + stagger(value: number | number[], config: Phaser.Types.Tweens.StaggerConfig): Function; + + /** + * Updates the Tween Manager's internal lists at the start of the frame. + * + * This method will return immediately if no changes have been indicated. + */ + preUpdate(): void; + + /** + * Updates all Tweens and Timelines of the Tween Manager. + * @param timestamp The current time in milliseconds. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update(timestamp: number, delta: number): void; + + /** + * Removes the given tween from the Tween Manager, regardless of its state (pending or active). + * @param tween The Tween to be removed. + */ + remove(tween: Phaser.Tweens.Tween): Phaser.Tweens.TweenManager; + + /** + * Checks if a Tween or Timeline is active and adds it to the Tween Manager at the start of the frame if it isn't. + * @param tween The Tween to check. + */ + makeActive(tween: Phaser.Tweens.Tween): Phaser.Tweens.TweenManager; + + /** + * Passes all Tweens to the given callback. + * @param callback The function to call. + * @param scope The scope (`this` object) to call the function with. + * @param args The arguments to pass into the function. Its first argument will always be the Tween currently being iterated. + */ + each(callback: Function, scope?: object, ...args: any[]): void; + + /** + * Returns an array of all active Tweens and Timelines in the Tween Manager. + */ + getAllTweens(): Phaser.Tweens.Tween[]; + + /** + * Returns the scale of the time delta for all Tweens and Timelines owned by this Tween Manager. + */ + getGlobalTimeScale(): number; + + /** + * Returns an array of all Tweens or Timelines in the Tween Manager which affect the given target or array of targets. + * + * Only the currently active tweens are tested. A tween that has completed and is + * awaiting removal will not be included in the results. + * + * If you wish to also search pending tweens, use the `includePending` flag. + * @param target The target to look for. Provide an array to look for multiple targets. + * @param includePending Also check for pending tweens, not just active ones? Default false. + */ + getTweensOf(target: object | any[], includePending?: boolean): Phaser.Tweens.Tween[]; + + /** + * Checks if the given object is being affected by a playing Tween. + * @param target target Phaser.Tweens.Tween object + */ + isTweening(target: object): boolean; + + /** + * Stops all Tweens in this Tween Manager. They will be removed at the start of the frame. + */ + killAll(): Phaser.Tweens.TweenManager; + + /** + * Stops all Tweens which affect the given target or array of targets. The Tweens will be removed from the Tween Manager at the start of the frame. + * @param target The target to look for. Provide an array to look for multiple targets. + */ + killTweensOf(target: object | any[]): Phaser.Tweens.TweenManager; + + /** + * Pauses all Tweens in this Tween Manager. + */ + pauseAll(): Phaser.Tweens.TweenManager; + + /** + * Resumes all Tweens in this Tween Manager. + */ + resumeAll(): Phaser.Tweens.TweenManager; + + /** + * Sets a new scale of the time delta for this Tween Manager. + * + * The time delta is the time elapsed between two consecutive frames and influences the speed of time for this Tween Manager and all Tweens it owns. Values higher than 1 increase the speed of time, while values smaller than 1 decrease it. A value of 0 freezes time and is effectively equivalent to pausing all Tweens. + * @param value The new scale of the time delta, where 1 is the normal speed. + */ + setGlobalTimeScale(value: number): Phaser.Tweens.TweenManager; + + /** + * The Scene that owns this plugin is shutting down. + * We need to kill and reset all internal properties as well as stop listening to Scene events. + */ + shutdown(): void; + + /** + * The Scene that owns this plugin is being destroyed. + * We need to shutdown and then kill off all external references. + */ + destroy(): void; + + } + namespace Builders { /** * Retrieves the value of the given key from an object. @@ -94942,374 +95443,6 @@ declare namespace Phaser { } - /** - * A Timeline combines multiple Tweens into one. Its overall behavior is otherwise similar to a single Tween. - * - * The Timeline updates all of its Tweens simultaneously. Its methods allow you to easily build a sequence - * of Tweens (each one starting after the previous one) or run multiple Tweens at once during given parts of the Timeline. - */ - class Timeline extends Phaser.Events.EventEmitter { - /** - * - * @param manager The Tween Manager which owns this Timeline. - */ - constructor(manager: Phaser.Tweens.TweenManager); - - /** - * The Tween Manager which owns this Timeline. - */ - manager: Phaser.Tweens.TweenManager; - - /** - * A constant value which allows this Timeline to be easily identified as one. - */ - isTimeline: boolean; - - /** - * An array of Tween objects, each containing a unique property and target being tweened. - */ - data: any[]; - - /** - * The cached size of the data array. - */ - totalData: number; - - /** - * If true then duration, delay, etc values are all frame totals, rather than ms. - */ - useFrames: boolean; - - /** - * Scales the time applied to this Timeline. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. - * Value isn't used when calculating total duration of the Timeline, it's a run-time delta adjustment only. - */ - timeScale: number; - - /** - * Loop this Timeline? Can be -1 for an infinite loop, or an integer. - * When enabled it will play through ALL Tweens again (use Tween.repeat to loop a single tween) - */ - loop: number; - - /** - * Time in ms/frames before this Timeline loops. - */ - loopDelay: number; - - /** - * How many loops are left to run? - */ - loopCounter: number; - - /** - * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = true (as it never completes) - */ - completeDelay: number; - - /** - * Countdown timer value, as used by `loopDelay` and `completeDelay`. - */ - countdown: number; - - /** - * The current state of the Timeline. - */ - state: number; - - /** - * Does the Timeline start off paused? (if so it needs to be started with Timeline.play) - */ - paused: boolean; - - /** - * Elapsed time in ms/frames of this run through of the Timeline. - */ - elapsed: number; - - /** - * Total elapsed time in ms/frames of the entire Timeline, including looping. - */ - totalElapsed: number; - - /** - * Time in ms/frames for the whole Timeline to play through once, excluding loop amounts and loop delays. - */ - duration: number; - - /** - * Value between 0 and 1. The amount of progress through the Timeline, _excluding loops_. - */ - progress: number; - - /** - * Time in ms/frames for all Tweens in this Timeline to complete (including looping) - */ - totalDuration: number; - - /** - * Value between 0 and 1. The amount through the entire Timeline, including looping. - */ - totalProgress: number; - - /** - * An object containing the different Tween callback functions. - * - * You can either set these in the Tween config, or by calling the `Tween.setCallback` method. - * - * `onComplete` When the Timeline finishes playback fully or `Timeline.stop` is called. Never invoked if timeline is set to repeat infinitely. - * `onLoop` When a Timeline loops. - * `onStart` When the Timeline starts playing. - * `onUpdate` When a Timeline updates a child Tween. - * `onYoyo` When a Timeline starts a yoyo. - */ - callbacks: object; - - /** - * The context in which all callbacks are invoked. - */ - callbackScope: any; - - /** - * Internal method that will emit a Timeline based Event and invoke the given callback. - * @param event The Event to be dispatched. - * @param callback The callback to be invoked. Can be `null` or `undefined` to skip invocation. - */ - dispatchTimelineEvent(event: Phaser.Types.Tweens.Event, callback: Function): void; - - /** - * Sets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. - * A value of 0.5 runs 50% slower, and so on. - * - * The value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. - * @param value The time scale value to set. - */ - setTimeScale(value: number): this; - - /** - * Gets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. - * A value of 0.5 runs 50% slower, and so on. - */ - getTimeScale(): number; - - /** - * Check whether or not the Timeline is playing. - */ - isPlaying(): boolean; - - /** - * Creates a new Tween, based on the given Tween Config, and adds it to this Timeline. - * @param config The configuration object for the Tween. - */ - add(config: Phaser.Types.Tweens.TweenBuilderConfig | object): this; - - /** - * Adds an existing Tween to this Timeline. - * @param tween The Tween to be added to this Timeline. - */ - queue(tween: Phaser.Tweens.Tween): this; - - /** - * Checks whether a Tween has an offset value. - * @param tween The Tween to check. - */ - hasOffset(tween: Phaser.Tweens.Tween): boolean; - - /** - * Checks whether the offset value is a number or a directive that is relative to previous tweens. - * @param value The offset value to be evaluated. - */ - isOffsetAbsolute(value: number): boolean; - - /** - * Checks if the offset is a relative value rather than an absolute one. - * If the value is just a number, this returns false. - * @param value The offset value to be evaluated. - */ - isOffsetRelative(value: string): boolean; - - /** - * Parses the relative offset value, returning a positive or negative number. - * @param value The relative offset, in the format of '-=500', for example. The first character determines whether it will be a positive or negative number. Spacing matters here. - * @param base The value to use as the offset. - */ - getRelativeOffset(value: string, base: number): number; - - /** - * Calculates the total duration of the timeline. - * - * Computes all tween durations and returns the full duration of the timeline. - * - * The resulting number is stored in the timeline, not as a return value. - */ - calcDuration(): void; - - /** - * Initializes the timeline, which means all Tweens get their init() called, and the total duration will be computed. - * Returns a boolean indicating whether the timeline is auto-started or not. - */ - init(): boolean; - - /** - * Resets all of the timeline's tweens back to their initial states. - * The boolean parameter indicates whether tweens that are looping should reset as well, or not. - * @param resetFromLoop If `true`, resets all looping tweens to their initial values. - */ - resetTweens(resetFromLoop: boolean): void; - - /** - * Sets a callback for the Timeline. - * @param type The internal type of callback to set. - * @param callback Timeline allows multiple tweens to be linked together to create a streaming sequence. - * @param params The parameters to pass to the callback. - * @param scope The context scope of the callback. - */ - setCallback(type: string, callback: Function, params?: any[], scope?: object): this; - - /** - * Passed a Tween to the Tween Manager and requests it be made active. - * @param tween The tween object to make active. - */ - makeActive(tween: Phaser.Tweens.Tween): Phaser.Tweens.TweenManager; - - /** - * Starts playing the Timeline. - */ - play(): void; - - /** - * Updates the Timeline's `state` and fires callbacks and events. - */ - nextState(): void; - - /** - * Returns 'true' if this Timeline has finished and should be removed from the Tween Manager. - * Otherwise, returns false. - * @param timestamp The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. - * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. - */ - update(timestamp: number, delta: number): boolean; - - /** - * Stops the Timeline immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. - */ - stop(): void; - - /** - * Pauses the Timeline, retaining its internal state. - * - * Calling this on a Timeline that is already paused has no effect and fires no event. - */ - pause(): this; - - /** - * Resumes a paused Timeline from where it was when it was paused. - * - * Calling this on a Timeline that isn't paused has no effect and fires no event. - */ - resume(): this; - - /** - * Checks if any of the Tweens in this Timeline as operating on the target object. - * - * Returns `false` if no Tweens operate on the target object. - * @param target The target to check all Tweens against. - */ - hasTarget(target: object): boolean; - - /** - * Stops all the Tweens in the Timeline immediately, whatever stage of progress they are at and flags - * them for removal by the TweenManager. - */ - destroy(): void; - - } - - /** - * TweenData state. - */ - var CREATED: number; - - /** - * TweenData state. - */ - var INIT: number; - - /** - * TweenData state. - */ - var DELAY: number; - - /** - * TweenData state. - */ - var OFFSET_DELAY: number; - - /** - * TweenData state. - */ - var PENDING_RENDER: number; - - /** - * TweenData state. - */ - var PLAYING_FORWARD: number; - - /** - * TweenData state. - */ - var PLAYING_BACKWARD: number; - - /** - * TweenData state. - */ - var HOLD_DELAY: number; - - /** - * TweenData state. - */ - var REPEAT_DELAY: number; - - /** - * TweenData state. - */ - var COMPLETE: number; - - /** - * Tween state. - */ - var PENDING_ADD: number; - - /** - * Tween state. - */ - var PAUSED: number; - - /** - * Tween state. - */ - var LOOP_DELAY: number; - - /** - * Tween state. - */ - var ACTIVE: number; - - /** - * Tween state. - */ - var COMPLETE_DELAY: number; - - /** - * Tween state. - */ - var PENDING_REMOVE: number; - - /** - * Tween state. - */ - var REMOVED: number; - /** * A Tween is able to manipulate the properties of one or more objects to any given value, based * on a duration and type of ease. They are rarely instantiated directly and instead should be @@ -95723,213 +95856,101 @@ declare namespace Phaser { function TweenData(target: any, index: number, key: string, getEnd: Function, getStart: Function, getActive: Function, ease: Function, delay: number, duration: number, yoyo: boolean, hold: number, repeat: number, repeatDelay: number, flipX: boolean, flipY: boolean): Phaser.Types.Tweens.TweenDataConfig; /** - * The Tween Manager is a default Scene Plugin which controls and updates Tweens and Timelines. + * TweenData state. */ - class TweenManager { - /** - * - * @param scene The Scene which owns this Tween Manager. - */ - constructor(scene: Phaser.Scene); + var CREATED: number; - /** - * The Scene which owns this Tween Manager. - */ - scene: Phaser.Scene; + /** + * TweenData state. + */ + var INIT: number; - /** - * The Systems object of the Scene which owns this Tween Manager. - */ - systems: Phaser.Scenes.Systems; + /** + * TweenData state. + */ + var DELAY: number; - /** - * The time scale of the Tween Manager. - * - * This value scales the time delta between two frames, thus influencing the speed of time for all Tweens owned by this Tween Manager. - */ - timeScale: number; + /** + * TweenData state. + */ + var OFFSET_DELAY: number; - /** - * Create a Tween Timeline and return it, but do NOT add it to the active or pending Tween lists. - * @param config The configuration object for the Timeline and its Tweens. - */ - createTimeline(config?: Phaser.Types.Tweens.TimelineBuilderConfig): Phaser.Tweens.Timeline; + /** + * TweenData state. + */ + var PENDING_RENDER: number; - /** - * Create a Tween Timeline and add it to the active Tween list. - * @param config The configuration object for the Timeline and its Tweens. - */ - timeline(config?: Phaser.Types.Tweens.TimelineBuilderConfig): Phaser.Tweens.Timeline; + /** + * TweenData state. + */ + var PLAYING_FORWARD: number; - /** - * Create a Tween and return it, but do NOT add it to the active or pending Tween lists. - * @param config The configuration object for the Tween. - */ - create(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.Tween; + /** + * TweenData state. + */ + var PLAYING_BACKWARD: number; - /** - * Create a Tween and add it to the active Tween list. - * @param config The configuration object for the Tween. - */ - add(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.Tween; + /** + * TweenData state. + */ + var HOLD_DELAY: number; - /** - * Add an existing tween into the active Tween list. - * @param tween The Tween to add. - */ - existing(tween: Phaser.Tweens.Tween): Phaser.Tweens.TweenManager; + /** + * TweenData state. + */ + var REPEAT_DELAY: number; - /** - * Create a Number Tween and add it to the active Tween list. - * @param config The configuration object for the Number Tween. - */ - addCounter(config: Phaser.Types.Tweens.NumberTweenBuilderConfig): Phaser.Tweens.Tween; + /** + * TweenData state. + */ + var COMPLETE: number; - /** - * Creates a Stagger function to be used by a Tween property. - * - * The stagger function will allow you to stagger changes to the value of the property across all targets of the tween. - * - * This is only worth using if the tween has multiple targets. - * - * The following will stagger the delay by 100ms across all targets of the tween, causing them to scale down to 0.2 - * over the duration specified: - * - * ```javascript - * this.tweens.add({ - * targets: [ ... ], - * scale: 0.2, - * ease: 'linear', - * duration: 1000, - * delay: this.tweens.stagger(100) - * }); - * ``` - * - * The following will stagger the delay by 500ms across all targets of the tween using a 10 x 6 grid, staggering - * from the center out, using a cubic ease. - * - * ```javascript - * this.tweens.add({ - * targets: [ ... ], - * scale: 0.2, - * ease: 'linear', - * duration: 1000, - * delay: this.tweens.stagger(500, { grid: [ 10, 6 ], from: 'center', ease: 'cubic.out' }) - * }); - * ``` - * @param value The amount to stagger by, or an array containing two elements representing the min and max values to stagger between. - * @param config The configuration object for the Stagger function. - */ - stagger(value: number | number[], config: Phaser.Types.Tweens.StaggerConfig): Function; + /** + * Tween state. + */ + var PENDING_ADD: number; - /** - * Updates the Tween Manager's internal lists at the start of the frame. - * - * This method will return immediately if no changes have been indicated. - */ - preUpdate(): void; + /** + * Tween state. + */ + var PAUSED: number; - /** - * Updates all Tweens and Timelines of the Tween Manager. - * @param timestamp The current time in milliseconds. - * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. - */ - update(timestamp: number, delta: number): void; + /** + * Tween state. + */ + var LOOP_DELAY: number; - /** - * Removes the given tween from the Tween Manager, regardless of its state (pending or active). - * @param tween The Tween to be removed. - */ - remove(tween: Phaser.Tweens.Tween): Phaser.Tweens.TweenManager; + /** + * Tween state. + */ + var ACTIVE: number; - /** - * Checks if a Tween or Timeline is active and adds it to the Tween Manager at the start of the frame if it isn't. - * @param tween The Tween to check. - */ - makeActive(tween: Phaser.Tweens.Tween): Phaser.Tweens.TweenManager; + /** + * Tween state. + */ + var COMPLETE_DELAY: number; - /** - * Passes all Tweens to the given callback. - * @param callback The function to call. - * @param scope The scope (`this` object) to call the function with. - * @param args The arguments to pass into the function. Its first argument will always be the Tween currently being iterated. - */ - each(callback: Function, scope?: object, ...args: any[]): void; + /** + * Tween state. + */ + var PENDING_REMOVE: number; - /** - * Returns an array of all active Tweens and Timelines in the Tween Manager. - */ - getAllTweens(): Phaser.Tweens.Tween[]; - - /** - * Returns the scale of the time delta for all Tweens and Timelines owned by this Tween Manager. - */ - getGlobalTimeScale(): number; - - /** - * Returns an array of all Tweens or Timelines in the Tween Manager which affect the given target or array of targets. - * - * Only the currently active tweens are tested. A tween that has completed and is - * awaiting removal will not be included in the results. - * - * If you wish to also search pending tweens, use the `includePending` flag. - * @param target The target to look for. Provide an array to look for multiple targets. - * @param includePending Also check for pending tweens, not just active ones? Default false. - */ - getTweensOf(target: object | any[], includePending?: boolean): Phaser.Tweens.Tween[]; - - /** - * Checks if the given object is being affected by a playing Tween. - * @param target target Phaser.Tweens.Tween object - */ - isTweening(target: object): boolean; - - /** - * Stops all Tweens in this Tween Manager. They will be removed at the start of the frame. - */ - killAll(): Phaser.Tweens.TweenManager; - - /** - * Stops all Tweens which affect the given target or array of targets. The Tweens will be removed from the Tween Manager at the start of the frame. - * @param target The target to look for. Provide an array to look for multiple targets. - */ - killTweensOf(target: object | any[]): Phaser.Tweens.TweenManager; - - /** - * Pauses all Tweens in this Tween Manager. - */ - pauseAll(): Phaser.Tweens.TweenManager; - - /** - * Resumes all Tweens in this Tween Manager. - */ - resumeAll(): Phaser.Tweens.TweenManager; - - /** - * Sets a new scale of the time delta for this Tween Manager. - * - * The time delta is the time elapsed between two consecutive frames and influences the speed of time for this Tween Manager and all Tweens it owns. Values higher than 1 increase the speed of time, while values smaller than 1 decrease it. A value of 0 freezes time and is effectively equivalent to pausing all Tweens. - * @param value The new scale of the time delta, where 1 is the normal speed. - */ - setGlobalTimeScale(value: number): Phaser.Tweens.TweenManager; - - /** - * The Scene that owns this plugin is shutting down. - * We need to kill and reset all internal properties as well as stop listening to Scene events. - */ - shutdown(): void; - - /** - * The Scene that owns this plugin is being destroyed. - * We need to shutdown and then kill off all external references. - */ - destroy(): void; - - } + /** + * Tween state. + */ + var REMOVED: number; } namespace Utils { + /** + * A NOOP (No Operation) callback function. + * + * Used internally by Phaser when it's more expensive to determine if a callback exists + * than it is to just invoke an empty function. + */ + function NOOP(): void; + namespace Array { /** * Adds the given item, or array of items, to the array. @@ -96064,220 +96085,6 @@ declare namespace Phaser { */ function GetRandom(array: any[], startIndex?: number, length?: number): any; - namespace Matrix { - /** - * Checks if an array can be used as a matrix. - * - * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) - * have the same length. There must be at least two rows. This is an example matrix: - * - * ``` - * [ - * [ 1, 1, 1, 1, 1, 1 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 2, 0, 1, 2, 0, 4 ], - * [ 2, 0, 3, 4, 0, 4 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 3, 3, 3, 3, 3, 3 ] - * ] - * ``` - * @param matrix The array to check. - */ - function CheckMatrix(matrix?: T[][]): boolean; - - /** - * Generates a string (which you can pass to console.log) from the given Array Matrix. - * - * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) - * have the same length. There must be at least two rows. This is an example matrix: - * - * ``` - * [ - * [ 1, 1, 1, 1, 1, 1 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 2, 0, 1, 2, 0, 4 ], - * [ 2, 0, 3, 4, 0, 4 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 3, 3, 3, 3, 3, 3 ] - * ] - * ``` - * @param matrix A 2-dimensional array. - */ - function MatrixToString(matrix?: T[][]): string; - - /** - * Reverses the columns in the given Array Matrix. - * - * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) - * have the same length. There must be at least two rows. This is an example matrix: - * - * ``` - * [ - * [ 1, 1, 1, 1, 1, 1 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 2, 0, 1, 2, 0, 4 ], - * [ 2, 0, 3, 4, 0, 4 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 3, 3, 3, 3, 3, 3 ] - * ] - * ``` - * @param matrix The array matrix to reverse the columns for. - */ - function ReverseColumns(matrix?: T[][]): T[][]; - - /** - * Reverses the rows in the given Array Matrix. - * - * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) - * have the same length. There must be at least two rows. This is an example matrix: - * - * ``` - * [ - * [ 1, 1, 1, 1, 1, 1 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 2, 0, 1, 2, 0, 4 ], - * [ 2, 0, 3, 4, 0, 4 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 3, 3, 3, 3, 3, 3 ] - * ] - * ``` - * @param matrix The array matrix to reverse the rows for. - */ - function ReverseRows(matrix?: T[][]): T[][]; - - /** - * Rotates the array matrix 180 degrees. - * - * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) - * have the same length. There must be at least two rows. This is an example matrix: - * - * ``` - * [ - * [ 1, 1, 1, 1, 1, 1 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 2, 0, 1, 2, 0, 4 ], - * [ 2, 0, 3, 4, 0, 4 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 3, 3, 3, 3, 3, 3 ] - * ] - * ``` - * @param matrix The array to rotate. - */ - function Rotate180(matrix?: T[][]): T[][]; - - /** - * Rotates the array matrix to the left (or 90 degrees) - * - * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) - * have the same length. There must be at least two rows. This is an example matrix: - * - * ``` - * [ - * [ 1, 1, 1, 1, 1, 1 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 2, 0, 1, 2, 0, 4 ], - * [ 2, 0, 3, 4, 0, 4 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 3, 3, 3, 3, 3, 3 ] - * ] - * ``` - * @param matrix The array to rotate. - */ - function RotateLeft(matrix?: T[][]): T[][]; - - /** - * Rotates the array matrix based on the given rotation value. - * - * The value can be given in degrees: 90, -90, 270, -270 or 180, - * or a string command: `rotateLeft`, `rotateRight` or `rotate180`. - * - * Based on the routine from {@link http://jsfiddle.net/MrPolywhirl/NH42z/}. - * - * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) - * have the same length. There must be at least two rows. This is an example matrix: - * - * ``` - * [ - * [ 1, 1, 1, 1, 1, 1 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 2, 0, 1, 2, 0, 4 ], - * [ 2, 0, 3, 4, 0, 4 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 3, 3, 3, 3, 3, 3 ] - * ] - * ``` - * @param matrix The array to rotate. - * @param direction The amount to rotate the matrix by. Default 90. - */ - function RotateMatrix(matrix?: T[][], direction?: number | string): T[][]; - - /** - * Rotates the array matrix to the left (or -90 degrees) - * - * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) - * have the same length. There must be at least two rows. This is an example matrix: - * - * ``` - * [ - * [ 1, 1, 1, 1, 1, 1 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 2, 0, 1, 2, 0, 4 ], - * [ 2, 0, 3, 4, 0, 4 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 3, 3, 3, 3, 3, 3 ] - * ] - * ``` - * @param matrix The array to rotate. - */ - function RotateRight(matrix?: T[][]): T[][]; - - /** - * Translates the given Array Matrix by shifting each column and row the - * amount specified. - * - * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) - * have the same length. There must be at least two rows. This is an example matrix: - * - * ``` - * [ - * [ 1, 1, 1, 1, 1, 1 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 2, 0, 1, 2, 0, 4 ], - * [ 2, 0, 3, 4, 0, 4 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 3, 3, 3, 3, 3, 3 ] - * ] - * ``` - * @param matrix The array matrix to translate. - * @param x The amount to horizontally translate the matrix by. Default 0. - * @param y The amount to vertically translate the matrix by. Default 0. - */ - function Translate(matrix?: T[][], x?: number, y?: number): T[][]; - - /** - * Transposes the elements of the given matrix (array of arrays). - * - * The transpose of a matrix is a new matrix whose rows are the columns of the original. - * - * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) - * have the same length. There must be at least two rows. This is an example matrix: - * - * ``` - * [ - * [ 1, 1, 1, 1, 1, 1 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 2, 0, 1, 2, 0, 4 ], - * [ 2, 0, 3, 4, 0, 4 ], - * [ 2, 0, 0, 0, 0, 4 ], - * [ 3, 3, 3, 3, 3, 3 ] - * ] - * ``` - * @param array The array matrix to transpose. - */ - function TransposeMatrix(array?: T[][]): T[][]; - - } - /** * Moves the given array element down one place in the array. * The array is modified in-place. @@ -96545,6 +96352,220 @@ declare namespace Phaser { */ function Swap(array: any[], item1: any, item2: any): any[]; + namespace Matrix { + /** + * Checks if an array can be used as a matrix. + * + * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) + * have the same length. There must be at least two rows. This is an example matrix: + * + * ``` + * [ + * [ 1, 1, 1, 1, 1, 1 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 2, 0, 1, 2, 0, 4 ], + * [ 2, 0, 3, 4, 0, 4 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 3, 3, 3, 3, 3, 3 ] + * ] + * ``` + * @param matrix The array to check. + */ + function CheckMatrix(matrix?: T[][]): boolean; + + /** + * Generates a string (which you can pass to console.log) from the given Array Matrix. + * + * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) + * have the same length. There must be at least two rows. This is an example matrix: + * + * ``` + * [ + * [ 1, 1, 1, 1, 1, 1 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 2, 0, 1, 2, 0, 4 ], + * [ 2, 0, 3, 4, 0, 4 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 3, 3, 3, 3, 3, 3 ] + * ] + * ``` + * @param matrix A 2-dimensional array. + */ + function MatrixToString(matrix?: T[][]): string; + + /** + * Reverses the columns in the given Array Matrix. + * + * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) + * have the same length. There must be at least two rows. This is an example matrix: + * + * ``` + * [ + * [ 1, 1, 1, 1, 1, 1 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 2, 0, 1, 2, 0, 4 ], + * [ 2, 0, 3, 4, 0, 4 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 3, 3, 3, 3, 3, 3 ] + * ] + * ``` + * @param matrix The array matrix to reverse the columns for. + */ + function ReverseColumns(matrix?: T[][]): T[][]; + + /** + * Reverses the rows in the given Array Matrix. + * + * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) + * have the same length. There must be at least two rows. This is an example matrix: + * + * ``` + * [ + * [ 1, 1, 1, 1, 1, 1 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 2, 0, 1, 2, 0, 4 ], + * [ 2, 0, 3, 4, 0, 4 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 3, 3, 3, 3, 3, 3 ] + * ] + * ``` + * @param matrix The array matrix to reverse the rows for. + */ + function ReverseRows(matrix?: T[][]): T[][]; + + /** + * Rotates the array matrix 180 degrees. + * + * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) + * have the same length. There must be at least two rows. This is an example matrix: + * + * ``` + * [ + * [ 1, 1, 1, 1, 1, 1 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 2, 0, 1, 2, 0, 4 ], + * [ 2, 0, 3, 4, 0, 4 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 3, 3, 3, 3, 3, 3 ] + * ] + * ``` + * @param matrix The array to rotate. + */ + function Rotate180(matrix?: T[][]): T[][]; + + /** + * Rotates the array matrix to the left (or 90 degrees) + * + * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) + * have the same length. There must be at least two rows. This is an example matrix: + * + * ``` + * [ + * [ 1, 1, 1, 1, 1, 1 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 2, 0, 1, 2, 0, 4 ], + * [ 2, 0, 3, 4, 0, 4 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 3, 3, 3, 3, 3, 3 ] + * ] + * ``` + * @param matrix The array to rotate. + */ + function RotateLeft(matrix?: T[][]): T[][]; + + /** + * Rotates the array matrix based on the given rotation value. + * + * The value can be given in degrees: 90, -90, 270, -270 or 180, + * or a string command: `rotateLeft`, `rotateRight` or `rotate180`. + * + * Based on the routine from {@link http://jsfiddle.net/MrPolywhirl/NH42z/}. + * + * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) + * have the same length. There must be at least two rows. This is an example matrix: + * + * ``` + * [ + * [ 1, 1, 1, 1, 1, 1 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 2, 0, 1, 2, 0, 4 ], + * [ 2, 0, 3, 4, 0, 4 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 3, 3, 3, 3, 3, 3 ] + * ] + * ``` + * @param matrix The array to rotate. + * @param direction The amount to rotate the matrix by. Default 90. + */ + function RotateMatrix(matrix?: T[][], direction?: number | string): T[][]; + + /** + * Rotates the array matrix to the left (or -90 degrees) + * + * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) + * have the same length. There must be at least two rows. This is an example matrix: + * + * ``` + * [ + * [ 1, 1, 1, 1, 1, 1 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 2, 0, 1, 2, 0, 4 ], + * [ 2, 0, 3, 4, 0, 4 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 3, 3, 3, 3, 3, 3 ] + * ] + * ``` + * @param matrix The array to rotate. + */ + function RotateRight(matrix?: T[][]): T[][]; + + /** + * Translates the given Array Matrix by shifting each column and row the + * amount specified. + * + * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) + * have the same length. There must be at least two rows. This is an example matrix: + * + * ``` + * [ + * [ 1, 1, 1, 1, 1, 1 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 2, 0, 1, 2, 0, 4 ], + * [ 2, 0, 3, 4, 0, 4 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 3, 3, 3, 3, 3, 3 ] + * ] + * ``` + * @param matrix The array matrix to translate. + * @param x The amount to horizontally translate the matrix by. Default 0. + * @param y The amount to vertically translate the matrix by. Default 0. + */ + function Translate(matrix?: T[][], x?: number, y?: number): T[][]; + + /** + * Transposes the elements of the given matrix (array of arrays). + * + * The transpose of a matrix is a new matrix whose rows are the columns of the original. + * + * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) + * have the same length. There must be at least two rows. This is an example matrix: + * + * ``` + * [ + * [ 1, 1, 1, 1, 1, 1 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 2, 0, 1, 2, 0, 4 ], + * [ 2, 0, 3, 4, 0, 4 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 3, 3, 3, 3, 3, 3 ] + * ] + * ``` + * @param array The array matrix to transpose. + */ + function TransposeMatrix(array?: T[][]): T[][]; + + } + } namespace Base64 { @@ -96567,14 +96588,6 @@ declare namespace Phaser { } - /** - * A NOOP (No Operation) callback function. - * - * Used internally by Phaser when it's more expensive to determine if a callback exists - * than it is to just invoke an empty function. - */ - function NOOP(): void; - namespace Objects { /** * Shallow Object Clone. Will not clone nested objects. @@ -96789,12 +96802,6 @@ declare namespace Phaser { */ function Reverse(string: string): string; - /** - * Capitalizes the first letter of a string if there is one. - * @param str The string to capitalize. - */ - function UppercaseFirst(str: string): string; - /** * Creates and returns an RFC4122 version 4 compliant UUID. * @@ -96803,6 +96810,12 @@ declare namespace Phaser { */ function UUID(): string; + /** + * Capitalizes the first letter of a string if there is one. + * @param str The string to capitalize. + */ + function UppercaseFirst(str: string): string; + } } @@ -97712,14 +97725,14 @@ declare type EachSetCallback = (entry: E, index: number)=>void; declare type EachTextureCallback = (texture: Phaser.Textures.Texture, ...args: any[])=>void; -declare type FindTileCallback = (value: Phaser.Tilemaps.Tile, index: number, array: Phaser.Tilemaps.Tile[])=>void; - -declare type EachTileCallback = (value: Phaser.Tilemaps.Tile, index: number, array: Phaser.Tilemaps.Tile[])=>void; - declare type TilemapFilterCallback = (value: Phaser.GameObjects.GameObject, index: number, array: Phaser.GameObjects.GameObject[])=>void; declare type TilemapFindCallback = (value: Phaser.GameObjects.GameObject, index: number, array: Phaser.GameObjects.GameObject[])=>void; +declare type FindTileCallback = (value: Phaser.Tilemaps.Tile, index: number, array: Phaser.Tilemaps.Tile[])=>void; + +declare type EachTileCallback = (value: Phaser.Tilemaps.Tile, index: number, array: Phaser.Tilemaps.Tile[])=>void; + /** * Phaser.Class */