From 7ab2f762b6a85b8964c4c28e66676052d83980d6 Mon Sep 17 00:00:00 2001 From: Yuval Greenfield Date: Mon, 3 Oct 2022 22:29:47 -0700 Subject: [PATCH 1/4] Scene types now can be an array of unions `SettingsConfig | CreateSceneFromObjectConfig` is a valid scene type. Now it will be allowed in GameConfig. --- types/phaser.d.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/types/phaser.d.ts b/types/phaser.d.ts index 7c9b0e9ef..25567aec9 100644 --- a/types/phaser.d.ts +++ b/types/phaser.d.ts @@ -12,6 +12,8 @@ declare type EachContainerCallback = (item: any, ...args: any[])=>void; declare type LightForEach = (light: Phaser.GameObjects.Light)=>void; +declare type SceneType = Phaser.Scene | Phaser.Types.Scenes.SettingsConfig | Phaser.Types.Scenes.CreateSceneFromObjectConfig | Function; + /** * A custom function that will be responsible for wrapping the text. */ @@ -61583,7 +61585,7 @@ declare namespace Phaser { /** * A scene or scenes to add to the game. If several are given, the first is started; the remainder are started only if they have `{ active: true }`. See the `sceneConfig` argument in `Phaser.Scenes.SceneManager#add`. */ - scene?: Phaser.Scene | Phaser.Scene[] | Phaser.Types.Scenes.SettingsConfig | Phaser.Types.Scenes.SettingsConfig[] | Phaser.Types.Scenes.CreateSceneFromObjectConfig | Phaser.Types.Scenes.CreateSceneFromObjectConfig[] | Function | Function[]; + scene?: SceneType | SceneType[]; /** * Seed for the random number generator. */ @@ -87818,7 +87820,7 @@ declare namespace Phaser { * @param autoStart If `true` the Scene will be started immediately after being added. Default false. * @param data Optional data object. This will be set as `Scene.settings.data` and passed to `Scene.init`, and `Scene.create`. */ - add(key: string, sceneConfig: Phaser.Scene | Phaser.Types.Scenes.SettingsConfig | Phaser.Types.Scenes.CreateSceneFromObjectConfig | Function, autoStart?: boolean, data?: object): Phaser.Scene | null; + add(key: string, sceneConfig: SceneType, autoStart?: boolean, data?: object): Phaser.Scene | null; /** * Removes a Scene from the SceneManager. @@ -88138,7 +88140,7 @@ declare namespace Phaser { * @param autoStart If `true` the Scene will be started immediately after being added. Default false. * @param data Optional data object. This will be set as `Scene.settings.data` and passed to `Scene.init`, and `Scene.create`. */ - add(key: string, sceneConfig: Phaser.Scene | Phaser.Types.Scenes.SettingsConfig | Phaser.Types.Scenes.CreateSceneFromObjectConfig | Function, autoStart?: boolean, data?: object): Phaser.Scene | null; + add(key: string, sceneConfig: SceneType, autoStart?: boolean, data?: object): Phaser.Scene | null; /** * Launch the given Scene and run it in parallel with this one. From 7a4dd97793631c01be92bc904cd63d9c29b40264 Mon Sep 17 00:00:00 2001 From: Yuval Greenfield Date: Tue, 4 Oct 2022 10:48:21 -0700 Subject: [PATCH 2/4] Fix the typescript types in the js This generates the desired phaser.d.ts --- scripts/tsgen/bin/Parser.js | 2 +- scripts/tsgen/bin/Parser.js.map | 2 +- scripts/tsgen/src/Parser.ts | 2 +- src/core/typedefs/GameConfig.js | 2 +- src/scene/SceneManager.js | 2 +- src/scene/ScenePlugin.js | 2 +- src/scene/typedefs/SceneType.js | 4 + types/phaser.d.ts | 29478 ++++++++++++++++-------------- 8 files changed, 15741 insertions(+), 13753 deletions(-) create mode 100644 src/scene/typedefs/SceneType.js diff --git a/scripts/tsgen/bin/Parser.js b/scripts/tsgen/bin/Parser.js index 81bc26cf1..1a24de374 100644 --- a/scripts/tsgen/bin/Parser.js +++ b/scripts/tsgen/bin/Parser.js @@ -25,7 +25,7 @@ class Parser { } emit() { let ignored = []; - let result = '/// \n\n'; + let result = '// DO NOT EDIT THIS FILE! It was generated by running `npm run tsgen`\n/// \n\n'; result = result.concat(this.topLevel.reduce((out, obj) => { return out + dom.emit(obj); }, '')); diff --git a/scripts/tsgen/bin/Parser.js.map b/scripts/tsgen/bin/Parser.js.map index 87c81a457..6978dffbe 100644 --- a/scripts/tsgen/bin/Parser.js.map +++ b/scripts/tsgen/bin/Parser.js.map @@ -1 +1 @@ -{"version":3,"file":"Parser.js","sourceRoot":"","sources":["../src/Parser.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAE/B,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAEzC,MAAa,MAAM;IAMf,YAAY,IAAW;QAEnB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QAErB,qDAAqD;QACrD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAExB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAE1B,yCAAyC;QACzC,yIAAyI;QACzI,kDAAkD;QAClD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAE9B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAE1B,oBAAoB;QACpB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAEjE,qBAAqB;QACrB,MAAM,kBAAkB,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAEvD,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;QAEnE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI;QAEA,IAAI,OAAO,GAAG,EAAE,CAAC;QAEjB,IAAI,MAAM,GAAG,wCAAwC,CAAC;QAEtD,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,GAA4B,EAAE,EAAE;YACtF,OAAO,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAER,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EACtB;YACI,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;YAC7C,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;SACxB;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAEO,YAAY,CAAC,IAAW;QAE5B,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;QAClF,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;QAElF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAElC,IAAI,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAErB,QAAQ,MAAM,CAAC,QAAQ,EACvB;gBACI,KAAK,qCAAqC,CAAC;gBAC3C,KAAK,2CAA2C,CAAC;gBACjD,KAAK,yCAAyC,CAAC;gBAC/C,KAAK,yCAAyC,CAAC;gBAC/C,KAAK,4CAA4C,CAAC;gBAClD,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,qCAAqC,CAAC;gBAC3C,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,kCAAkC,CAAC;gBACxC,KAAK,yCAAyC,CAAC;gBAC/C,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,sCAAsC,CAAC;gBAC5C,KAAK,4CAA4C,CAAC;gBAClD,KAAK,wCAAwC,CAAC;gBAC9C,KAAK,4CAA4C,CAAC;gBAClD,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,uCAAuC,CAAC;gBAC7C,KAAK,2CAA2C,CAAC;gBACjD,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,sCAAsC,CAAC;gBAC5C,KAAK,yCAAyC,CAAC;gBAC/C,KAAK,uCAAuC;oBACxC,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC;oBACtB,MAAM;gBAEV,+BAA+B;gBAC/B,KAAK,mBAAmB,CAAC;gBACzB,KAAK,mBAAmB,CAAC;gBACzB,KAAK,4BAA4B,CAAC;gBAClC,KAAK,gCAAgC,CAAC;gBACtC,KAAK,qBAAqB,CAAC;gBAC3B,KAAK,0BAA0B,CAAC;gBAChC,KAAK,yBAAyB,CAAC;gBAC/B,KAAK,mBAAmB,CAAC;gBACzB,KAAK,4BAA4B,CAAC;gBAClC,KAAK,6BAA6B,CAAC;gBACnC,KAAK,sBAAsB;oBACvB,sDAAsD;oBACtD,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC;oBACvB,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC;oBACrB,MAAM;aACb;YAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,mCAAmC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,mCAAmC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,mCAAmC,CAAC,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EACvP;gBACI,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC;aACzB;YAED,kEAAkE;YAElE,IAAI,GAAwB,CAAC;YAC7B,IAAI,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC;YAE7B,QAAQ,MAAM,CAAC,IAAI,EAAE;gBACjB,KAAK,WAAW;oBACZ,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;oBACnC,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC;oBAC5B,MAAM;gBACV,KAAK,OAAO;oBACR,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;oBAC/B,MAAM;gBACV,KAAK,OAAO;oBACR,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;oBACnC,MAAM;gBACV,KAAK,QAAQ;oBACT,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,EAAE;wBACxB,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;wBAC9B,MAAM;qBACT;gBACL,KAAK,UAAU;oBACX,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;oBAChC,MAAM;gBACV,KAAK,UAAU;oBACX,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;oBAClC,MAAM;gBACV,KAAK,SAAS;oBACV,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;oBACjC,MAAM;gBACV,KAAK,OAAO;oBACR,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;oBAC/B,MAAM;gBACV;oBACI,OAAO,CAAC,GAAG,CAAC,uBAAuB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;oBACnD,MAAM;aACb;YAED,IAAI,GAAG,EACP;gBACI,IAAI,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAC9B;oBACI,OAAO,CAAC,GAAG,CAAC,wCAAwC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;oBACxE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;oBACpB,SAAS;iBACZ;gBAED,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC;gBAEjC,IAAI,MAAM,CAAC,WAAW,EACtB;oBACI,IAAI,SAAS,GAAG,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;oBACvC,GAAG,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;iBACnF;aACJ;SACJ;IACL,CAAC;IAEO,cAAc,CAAC,IAAW;QAE9B,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;QAClF,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/B,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;QAElF,IAAI,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;QAEjC,KAAK,IAAI,MAAM,IAAI,IAAI,EACvB;YACI,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAE3G,IAAI,CAAC,GAAG,EACR;gBACI,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,YAAY,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;gBACzD,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;gBAE3C,SAAS;aACZ;YAED,IAAI,CAAC,MAAM,CAAC,QAAQ,EACpB;gBACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAA8B,CAAC,CAAC;aACtD;iBAED;gBACI,IAAI,iBAAiB,GAAG,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,IAAI,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC;gBAE5H,IAAI,MAAM,GAAG,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAExI,IAAI,CAAC,MAAM,EACX;oBACI,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,YAAY,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;oBACzD,OAAO,CAAC,GAAG,CAAC,mBAAmB,MAAM,CAAC,QAAQ,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,gBAAgB,MAAM,CAAC,QAAQ,wBAAwB,CAAC,CAAC;iBAC3J;gBAED,IAAU,MAAO,CAAC,OAAO,EACzB;oBACU,MAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;iBACnC;qBAED;oBACI,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,YAAY,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;oBACzD,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;oBAC5C,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;iBACvB;gBAEK,GAAI,CAAC,OAAO,GAAG,MAAM,CAAC;gBAE5B,wDAAwD;gBACxD,IAAI,CAAE,MAAc,CAAC,IAAI,KAAK,OAAO,IAAK,MAAc,CAAC,IAAI,KAAK,WAAW,CAAC,IAAK,GAAW,CAAC,IAAI,KAAK,UAAU,EAClH;oBACK,GAAW,CAAC,IAAI,GAAG,QAAQ,CAAC;iBAChC;gBAED,uDAAuD;gBACvD,IAAK,MAAc,CAAC,IAAI,KAAK,WAAW,IAAK,GAAW,CAAC,IAAI,KAAK,UAAU,EAC5E;oBACI,IAAI,MAAM,CAAC,IAAI,IAAI,UAAU,EAC7B;wBACK,GAAW,CAAC,IAAI,GAAG,OAAO,CAAC;qBAC/B;yBAED;wBACK,GAAW,CAAC,IAAI,GAAG,KAAK,CAAC;qBAC7B;iBACJ;aACJ;SACJ;IACL,CAAC;IAEO,kBAAkB,CAAC,IAAW;QAElC,KAAK,IAAI,MAAM,IAAI,IAAI,EACvB;YACI,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAEzG,IAAI,CAAC,GAAG,EACR;gBACI,OAAO,CAAC,GAAG,CAAC,oBAAoB,MAAM,CAAC,QAAQ,MAAM,CAAC,CAAC;gBACvD,SAAS;aACZ;YAED,IAAI,CAAO,GAAI,CAAC,OAAO;gBAAE,SAAS;YAElC,IAAI,MAAM,CAAC,SAAS,EACpB;gBACI,4DAA4D;gBAC5D,IAAI,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAEzC,IAAI,CAAC,IAAI,IAAI,CAAO,IAAK,CAAC,OAAO,EACjC;oBACI,MAAM,IAAI,MAAM,CAAC,QAAQ,0BAA0B,MAAM,CAAC,QAAQ,0BAA0B,CAAC;iBAChG;gBAED,IAAU,IAAK,CAAC,OAAO,CAAC,IAAI,IAAI,WAAW,EAC3C;oBACU,GAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAO,GAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;oBACxE,GAAI,CAAC,OAAO,GAAG,IAAI,CAAC;iBAC7B;aACJ;SACJ;IACL,CAAC;IAEO,cAAc,CAAC,IAAW;QAC9B,KAAK,IAAI,MAAM,IAAI,IAAI,EAAE;YACrB,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACxC,IAAI,CAAC,GAAG,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO;gBAAE,SAAS;YAE9C,IAAI,CAAC,GAAG,GAA2B,CAAC;YAEpC,mBAAmB;YACnB,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;gBAC3C,KAAK,IAAI,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE;oBACjC,IAAI,IAAI,GAAW,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;oBAEjD,IAAI,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA,2EAA2E;oBAEtH,IAAI,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAoD,CAAC;oBAE7F,IAAI,CAAC,QAAQ,EAAE;wBACX,OAAO,CAAC,GAAG,CAAC,kCAAkC,OAAO,QAAQ,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;qBACnF;yBAAM;wBACH,IAAI,QAAQ,CAAC,IAAI,IAAI,OAAO,EAAE;4BAC1B,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;yBACvC;6BAAM;4BACH,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;yBACjD;qBACJ;iBACJ;aACJ;SACJ;IACL,CAAC;IAEO,eAAe,CAAC,MAAW;QAE/B;;;;;;;;;;;;;;;WAeG;QAEC,8CAA8C;QAElD,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAE5C,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,WAAW,CAAC,MAAW;QAC3B,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAExC,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,IAAI,MAAM,CAAC,MAAM,EAAE;YACf,IAAI,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACxC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC7B,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;YAEzB,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,IAAK,CAAC,OAAO,GAAG,GAAG,CAAC;SAC7B;QAED,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAEzC,IAAI,MAAM,CAAC,SAAS;YAChB,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,+BAA+B;QAExG,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,eAAe,CAAC,MAAW;QAC/B,OAAO,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAEO,YAAY,CAAC,MAAW;QAC5B,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAElC,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEjD,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAEvC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,WAAW,CAAC,MAAW;QAE3B,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAElC,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAE9C,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,UAAU,CAAC,MAAW;QAC1B,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAE9C,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,cAAc,CAAC,MAAW;QAC9B,IAAI,UAAU,GAAa,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;QAEzC,IAAI,MAAM,CAAC,OAAO,EAAE;YAChB,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;SAClD;QAED,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;QAC7D,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE5B,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;QAEjD,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,aAAa,CAAC,MAAW;QAC7B,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACtC,IAAI,IAAI,GAAG,IAAI,CAAC;QAEhB,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;YACnC,IAAI,UAAU,GAAG,EAAE,CAAC;YAEpB,KAAK,IAAI,OAAO,IAAI,MAAM,CAAC,UAAU,EAAE;gBACnC,IAAI,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;gBACtC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACtB,IAAI,OAAO,CAAC,WAAW;oBACnB,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;aAC7E;YAED,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YAEzC,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;gBAC3C,IAAI,iBAAiB,GAAG,EAAE,CAAC;gBAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBAC7C,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBAC7E;gBACD,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC7B,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;aACrD;SAEJ;aAAM;YACH,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE;gBACpC,IAAI,UAAU,GAAa,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;gBACzC,IAAI,MAAM,CAAC,OAAO,EAAE;oBAChB,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;iBAClD;gBACD,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;gBACjD,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;aAChC;iBAAM;gBACH,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;aACjC;SACJ;QAED,IAAI,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEhD,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QAEzC,OAAO,KAAK,CAAC;IACjB,CAAC;IAEO,SAAS,CAAC,MAAW,EAAE,GAAyD;QACpF,IAAI,UAAU,GAAoB,EAAE,CAAC;QAErC,IAAI,MAAM,CAAC,IAAI,EAAE;YACb,IAAI,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACjD,IAAI,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;YACzE,IAAI,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAEtD,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC1B;QAED,IAAI,MAAM,CAAC,MAAM,EAAE;YAEf,IAAI,QAAQ,GAAG,KAAK,CAAC;YAErB,GAAG,CAAC,YAAY,GAAG,EAAE,CAAC;YAEtB,KAAK,IAAI,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE;gBAEhC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAClB;oBACI,OAAO,CAAC,GAAG,CAAC,kBAAkB,MAAM,CAAC,QAAQ,QAAQ,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;oBAEnG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;iBAC1B;gBAED,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE;oBAElC,OAAO,CAAC,GAAG,CAAC,yCAAyC,MAAM,CAAC,QAAQ,QAAQ,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;oBAE1H,IAAI,UAAU,GAAG,QAAQ,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;oBAEzG,IAAI,QAAQ,CAAC,WAAW;wBACpB,GAAG,CAAC,YAAY,IAAI,YAAY,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,GAAG,UAAU,CAAC;yBAClH,IAAI,UAAU,CAAC,MAAM;wBACtB,GAAG,CAAC,YAAY,IAAI,YAAY,QAAQ,CAAC,IAAI,GAAG,GAAG,UAAU,CAAC;oBAClE,SAAS;iBACZ;gBAED,IAAI,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC9F,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAEvB,IAAI,QAAQ,IAAI,QAAQ,CAAC,QAAQ,IAAI,IAAI,EAAE;oBACvC,OAAO,CAAC,GAAG,CAAC,+CAA+C,QAAQ,CAAC,IAAI,UAAU,MAAM,CAAC,QAAQ,QAAQ,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;oBACvJ,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC;iBAC5B;gBAED,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;gBAEnC,QAAQ,GAAG,QAAQ,IAAI,QAAQ,CAAC,QAAQ,KAAK,IAAI,CAAC;gBAElD,IAAI,UAAU,GAAG,QAAQ,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBAEzG,IAAI,QAAQ,CAAC,WAAW;oBACpB,GAAG,CAAC,YAAY,IAAI,YAAY,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,GAAG,UAAU,CAAC;qBAClH,IAAI,UAAU,CAAC,MAAM;oBACtB,GAAG,CAAC,YAAY,IAAI,YAAY,QAAQ,CAAC,IAAI,GAAG,GAAG,UAAU,CAAC;aACrE;SACJ;QAED,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC;IAChC,CAAC;IAEO,SAAS,CAAC,OAAY,EAAE,YAAY,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI;QACxD,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;YAC3B,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;SACvB;aAAM;YACH,IAAI,KAAK,GAAG,EAAE,CAAC;YACf,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE;gBAEjC,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;gBAElC,IAAI,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;gBAErE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACpB;YACD,IAAI,OAAO,CAAC,QAAQ,EAAE;gBAClB,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;aAC5B;YACD,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC;gBAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;;gBAClC,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACvC;IACL,CAAC;IAEO,eAAe,CAAC,IAAY;QAChC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE;YACzB,IAAI,GAAY,IAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAChD;QACD,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,KAAK,oBAAoB,EAAE;YAC3D,IAAI,GAAY,IAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAC/C;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,eAAe,CAAC,IAAY;QAChC,IAAI,IAAI,KAAK,OAAO;YAAE,OAAO,QAAQ,CAAC;QACtC,IAAI,IAAI,KAAK,UAAU;YAAE,OAAO,UAAU,CAAC;QAC3C,IAAI,IAAI,KAAK,oBAAoB;YAAE,OAAO,YAAY,CAAC;QACvD,IAAI,IAAI,KAAK,OAAO;YAAE,OAAO,OAAO,CAAC;QAErC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;YAC3B,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;YAE1C,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;gBACvB,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;aAClD;SACJ;aAAM,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YACnC,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YAE3C,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;gBACvB,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE;oBAC/B,IAAI,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBAClC,OAAO,UAAU,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;iBAC1F;qBAAM;oBACH,OAAO,mBAAmB,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;iBACjE;aACJ;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,YAAY,CAAC,MAAW,EAAE,GAAwC;QACtE,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC;QACtC,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,EAAE;YAC1B,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC;YACrC,IAAI,IAAI,GAAwB,GAAI,CAAC,IAAI,CAAC;YAC1C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBAC3B,IAAI,IAAI,CAAC,IAAI,IAAI,KAAK;oBAClB,OAAO,CAAC,GAAG,CAAC,uDAAuD,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAC1F,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,mBAAmB;aACpD;SACJ;aAAM,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,EAAE,EAAC,qDAAqD;YACvF,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,WAAW;gBAAE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC;;gBACrE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,QAAQ,CAAC;SACnD;QACD,QAAQ,MAAM,CAAC,MAAM,EAAE;YACnB,KAAK,WAAW;gBACZ,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,SAAS,CAAC;gBAC5C,MAAM;YACV,KAAK,SAAS;gBACV,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,OAAO,CAAC;gBAC1C,MAAM;SACb;QACD,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU;YAAE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,QAAQ,CAAC;QAC9F,IAAI,MAAM,CAAC,KAAK,KAAK,QAAQ;YAAE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC;IAC5E,CAAC;IAEO,cAAc,CAAC,MAAW,EAAE,GAAwG,EAAE,MAAuB;QACjK,IAAI,MAAM,CAAC,IAAI;YACX,KAAK,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,EAAE;gBACzB,IAAI,GAAG,CAAC,aAAa,KAAK,SAAS,EAAE;oBAEjC;;;;;;uBAMG;oBACH,MAAM,OAAO,GAAY,GAAG,CAAC,KAAM,CAAC,KAAK,CAAC,+EAA+E,CAAC,CAAC;oBAC3H,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,CAAC,GAAG,OAAO,CAAC;oBAE9D,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,CACtC,KAAK,EACL,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CACzD,CAAC;oBAEF,IAAG,YAAY,IAAI,IAAI,EAAE;wBACrB,SAAS,CAAC,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;qBAClE;oBAE2E,GAAI,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBAChH,eAAe,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;iBAExC;qBAAM,IAAI,GAAG,CAAC,aAAa,KAAK,YAAY,EAAE;oBAC3C,IAAI,OAAO,GAAY,GAAG,CAAC,KAAM,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;oBAC7F,IAAI,YAAY,GAAW,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;oBAE5D,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC;iBACnE;aACJ;QAEL,SAAS,eAAe,CAAC,aAAqB,EAAE,YAAoB;YAChE,IAAI,aAAa,IAAI,IAAI,EAAE;gBACvB,IAAI,SAAS,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACzC,IAAI,MAAM,IAAI,IAAI,EAAE;oBAChB,KAAK,IAAI,KAAK,IAAI,MAAM,EAAE;wBACtB,IAAI,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE;4BACrC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;yBAC5D;qBACJ;iBACJ;gBACD,IAAI,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,EAAC,kCAAkC;oBAC7C,GAAI,CAAC,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;iBAC3F;gBACD,IAAI,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAC,gCAAgC;oBACzC,GAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;iBACrF;aACJ;QACL,CAAC;IACL,CAAC;CAEJ;AA7oBD,wBA6oBC"} \ No newline at end of file +{"version":3,"file":"Parser.js","sourceRoot":"","sources":["../src/Parser.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAE/B,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAEzC,MAAa,MAAM;IAMf,YAAY,IAAW;QAEnB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QAErB,qDAAqD;QACrD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAExB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAE1B,yCAAyC;QACzC,yIAAyI;QACzI,kDAAkD;QAClD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAE9B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAE1B,oBAAoB;QACpB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAEjE,qBAAqB;QACrB,MAAM,kBAAkB,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAEvD,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;QAEnE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI;QAEA,IAAI,OAAO,GAAG,EAAE,CAAC;QAEjB,IAAI,MAAM,GAAG,+GAA+G,CAAC;QAE7H,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,GAA4B,EAAE,EAAE;YACtF,OAAO,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAER,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EACtB;YACI,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;YAC7C,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;SACxB;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAEO,YAAY,CAAC,IAAW;QAE5B,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;QAClF,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;QAElF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAElC,IAAI,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAErB,QAAQ,MAAM,CAAC,QAAQ,EACvB;gBACI,KAAK,qCAAqC,CAAC;gBAC3C,KAAK,2CAA2C,CAAC;gBACjD,KAAK,yCAAyC,CAAC;gBAC/C,KAAK,yCAAyC,CAAC;gBAC/C,KAAK,4CAA4C,CAAC;gBAClD,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,qCAAqC,CAAC;gBAC3C,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,kCAAkC,CAAC;gBACxC,KAAK,yCAAyC,CAAC;gBAC/C,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,sCAAsC,CAAC;gBAC5C,KAAK,4CAA4C,CAAC;gBAClD,KAAK,wCAAwC,CAAC;gBAC9C,KAAK,4CAA4C,CAAC;gBAClD,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,uCAAuC,CAAC;gBAC7C,KAAK,2CAA2C,CAAC;gBACjD,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,sCAAsC,CAAC;gBAC5C,KAAK,yCAAyC,CAAC;gBAC/C,KAAK,uCAAuC;oBACxC,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC;oBACtB,MAAM;gBAEV,+BAA+B;gBAC/B,KAAK,mBAAmB,CAAC;gBACzB,KAAK,mBAAmB,CAAC;gBACzB,KAAK,4BAA4B,CAAC;gBAClC,KAAK,gCAAgC,CAAC;gBACtC,KAAK,qBAAqB,CAAC;gBAC3B,KAAK,0BAA0B,CAAC;gBAChC,KAAK,yBAAyB,CAAC;gBAC/B,KAAK,mBAAmB,CAAC;gBACzB,KAAK,4BAA4B,CAAC;gBAClC,KAAK,6BAA6B,CAAC;gBACnC,KAAK,sBAAsB;oBACvB,sDAAsD;oBACtD,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC;oBACvB,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC;oBACrB,MAAM;aACb;YAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,mCAAmC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,mCAAmC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,mCAAmC,CAAC,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EACvP;gBACI,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC;aACzB;YAED,kEAAkE;YAElE,IAAI,GAAwB,CAAC;YAC7B,IAAI,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC;YAE7B,QAAQ,MAAM,CAAC,IAAI,EAAE;gBACjB,KAAK,WAAW;oBACZ,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;oBACnC,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC;oBAC5B,MAAM;gBACV,KAAK,OAAO;oBACR,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;oBAC/B,MAAM;gBACV,KAAK,OAAO;oBACR,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;oBACnC,MAAM;gBACV,KAAK,QAAQ;oBACT,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,EAAE;wBACxB,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;wBAC9B,MAAM;qBACT;gBACL,KAAK,UAAU;oBACX,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;oBAChC,MAAM;gBACV,KAAK,UAAU;oBACX,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;oBAClC,MAAM;gBACV,KAAK,SAAS;oBACV,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;oBACjC,MAAM;gBACV,KAAK,OAAO;oBACR,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;oBAC/B,MAAM;gBACV;oBACI,OAAO,CAAC,GAAG,CAAC,uBAAuB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;oBACnD,MAAM;aACb;YAED,IAAI,GAAG,EACP;gBACI,IAAI,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAC9B;oBACI,OAAO,CAAC,GAAG,CAAC,wCAAwC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;oBACxE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;oBACpB,SAAS;iBACZ;gBAED,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC;gBAEjC,IAAI,MAAM,CAAC,WAAW,EACtB;oBACI,IAAI,SAAS,GAAG,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;oBACvC,GAAG,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;iBACnF;aACJ;SACJ;IACL,CAAC;IAEO,cAAc,CAAC,IAAW;QAE9B,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;QAClF,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/B,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;QAElF,IAAI,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;QAEjC,KAAK,IAAI,MAAM,IAAI,IAAI,EACvB;YACI,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAE3G,IAAI,CAAC,GAAG,EACR;gBACI,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,YAAY,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;gBACzD,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;gBAE3C,SAAS;aACZ;YAED,IAAI,CAAC,MAAM,CAAC,QAAQ,EACpB;gBACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAA8B,CAAC,CAAC;aACtD;iBAED;gBACI,IAAI,iBAAiB,GAAG,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,IAAI,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC;gBAE5H,IAAI,MAAM,GAAG,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAExI,IAAI,CAAC,MAAM,EACX;oBACI,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,YAAY,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;oBACzD,OAAO,CAAC,GAAG,CAAC,mBAAmB,MAAM,CAAC,QAAQ,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,gBAAgB,MAAM,CAAC,QAAQ,wBAAwB,CAAC,CAAC;iBAC3J;gBAED,IAAU,MAAO,CAAC,OAAO,EACzB;oBACU,MAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;iBACnC;qBAED;oBACI,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,YAAY,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;oBACzD,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;oBAC5C,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;iBACvB;gBAEK,GAAI,CAAC,OAAO,GAAG,MAAM,CAAC;gBAE5B,wDAAwD;gBACxD,IAAI,CAAE,MAAc,CAAC,IAAI,KAAK,OAAO,IAAK,MAAc,CAAC,IAAI,KAAK,WAAW,CAAC,IAAK,GAAW,CAAC,IAAI,KAAK,UAAU,EAClH;oBACK,GAAW,CAAC,IAAI,GAAG,QAAQ,CAAC;iBAChC;gBAED,uDAAuD;gBACvD,IAAK,MAAc,CAAC,IAAI,KAAK,WAAW,IAAK,GAAW,CAAC,IAAI,KAAK,UAAU,EAC5E;oBACI,IAAI,MAAM,CAAC,IAAI,IAAI,UAAU,EAC7B;wBACK,GAAW,CAAC,IAAI,GAAG,OAAO,CAAC;qBAC/B;yBAED;wBACK,GAAW,CAAC,IAAI,GAAG,KAAK,CAAC;qBAC7B;iBACJ;aACJ;SACJ;IACL,CAAC;IAEO,kBAAkB,CAAC,IAAW;QAElC,KAAK,IAAI,MAAM,IAAI,IAAI,EACvB;YACI,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAEzG,IAAI,CAAC,GAAG,EACR;gBACI,OAAO,CAAC,GAAG,CAAC,oBAAoB,MAAM,CAAC,QAAQ,MAAM,CAAC,CAAC;gBACvD,SAAS;aACZ;YAED,IAAI,CAAO,GAAI,CAAC,OAAO;gBAAE,SAAS;YAElC,IAAI,MAAM,CAAC,SAAS,EACpB;gBACI,4DAA4D;gBAC5D,IAAI,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAEzC,IAAI,CAAC,IAAI,IAAI,CAAO,IAAK,CAAC,OAAO,EACjC;oBACI,MAAM,IAAI,MAAM,CAAC,QAAQ,0BAA0B,MAAM,CAAC,QAAQ,0BAA0B,CAAC;iBAChG;gBAED,IAAU,IAAK,CAAC,OAAO,CAAC,IAAI,IAAI,WAAW,EAC3C;oBACU,GAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAO,GAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;oBACxE,GAAI,CAAC,OAAO,GAAG,IAAI,CAAC;iBAC7B;aACJ;SACJ;IACL,CAAC;IAEO,cAAc,CAAC,IAAW;QAC9B,KAAK,IAAI,MAAM,IAAI,IAAI,EAAE;YACrB,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACxC,IAAI,CAAC,GAAG,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO;gBAAE,SAAS;YAE9C,IAAI,CAAC,GAAG,GAA2B,CAAC;YAEpC,mBAAmB;YACnB,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;gBAC3C,KAAK,IAAI,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE;oBACjC,IAAI,IAAI,GAAW,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;oBAEjD,IAAI,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA,2EAA2E;oBAEtH,IAAI,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAoD,CAAC;oBAE7F,IAAI,CAAC,QAAQ,EAAE;wBACX,OAAO,CAAC,GAAG,CAAC,kCAAkC,OAAO,QAAQ,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;qBACnF;yBAAM;wBACH,IAAI,QAAQ,CAAC,IAAI,IAAI,OAAO,EAAE;4BAC1B,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;yBACvC;6BAAM;4BACH,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;yBACjD;qBACJ;iBACJ;aACJ;SACJ;IACL,CAAC;IAEO,eAAe,CAAC,MAAW;QAE/B;;;;;;;;;;;;;;;WAeG;QAEC,8CAA8C;QAElD,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAE5C,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,WAAW,CAAC,MAAW;QAC3B,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAExC,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,IAAI,MAAM,CAAC,MAAM,EAAE;YACf,IAAI,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACxC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC7B,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;YAEzB,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,IAAK,CAAC,OAAO,GAAG,GAAG,CAAC;SAC7B;QAED,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAEzC,IAAI,MAAM,CAAC,SAAS;YAChB,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,+BAA+B;QAExG,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,eAAe,CAAC,MAAW;QAC/B,OAAO,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAEO,YAAY,CAAC,MAAW;QAC5B,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAElC,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEjD,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAEvC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,WAAW,CAAC,MAAW;QAE3B,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAElC,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAE9C,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,UAAU,CAAC,MAAW;QAC1B,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAE9C,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,cAAc,CAAC,MAAW;QAC9B,IAAI,UAAU,GAAa,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;QAEzC,IAAI,MAAM,CAAC,OAAO,EAAE;YAChB,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;SAClD;QAED,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;QAC7D,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE5B,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;QAEjD,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,aAAa,CAAC,MAAW;QAC7B,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACtC,IAAI,IAAI,GAAG,IAAI,CAAC;QAEhB,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;YACnC,IAAI,UAAU,GAAG,EAAE,CAAC;YAEpB,KAAK,IAAI,OAAO,IAAI,MAAM,CAAC,UAAU,EAAE;gBACnC,IAAI,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;gBACtC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACtB,IAAI,OAAO,CAAC,WAAW;oBACnB,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;aAC7E;YAED,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YAEzC,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;gBAC3C,IAAI,iBAAiB,GAAG,EAAE,CAAC;gBAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBAC7C,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBAC7E;gBACD,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC7B,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;aACrD;SAEJ;aAAM;YACH,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE;gBACpC,IAAI,UAAU,GAAa,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;gBACzC,IAAI,MAAM,CAAC,OAAO,EAAE;oBAChB,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;iBAClD;gBACD,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;gBACjD,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;aAChC;iBAAM;gBACH,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;aACjC;SACJ;QAED,IAAI,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEhD,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QAEzC,OAAO,KAAK,CAAC;IACjB,CAAC;IAEO,SAAS,CAAC,MAAW,EAAE,GAAyD;QACpF,IAAI,UAAU,GAAoB,EAAE,CAAC;QAErC,IAAI,MAAM,CAAC,IAAI,EAAE;YACb,IAAI,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACjD,IAAI,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;YACzE,IAAI,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAEtD,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC1B;QAED,IAAI,MAAM,CAAC,MAAM,EAAE;YAEf,IAAI,QAAQ,GAAG,KAAK,CAAC;YAErB,GAAG,CAAC,YAAY,GAAG,EAAE,CAAC;YAEtB,KAAK,IAAI,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE;gBAEhC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAClB;oBACI,OAAO,CAAC,GAAG,CAAC,kBAAkB,MAAM,CAAC,QAAQ,QAAQ,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;oBAEnG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;iBAC1B;gBAED,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE;oBAElC,OAAO,CAAC,GAAG,CAAC,yCAAyC,MAAM,CAAC,QAAQ,QAAQ,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;oBAE1H,IAAI,UAAU,GAAG,QAAQ,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;oBAEzG,IAAI,QAAQ,CAAC,WAAW;wBACpB,GAAG,CAAC,YAAY,IAAI,YAAY,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,GAAG,UAAU,CAAC;yBAClH,IAAI,UAAU,CAAC,MAAM;wBACtB,GAAG,CAAC,YAAY,IAAI,YAAY,QAAQ,CAAC,IAAI,GAAG,GAAG,UAAU,CAAC;oBAClE,SAAS;iBACZ;gBAED,IAAI,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC9F,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAEvB,IAAI,QAAQ,IAAI,QAAQ,CAAC,QAAQ,IAAI,IAAI,EAAE;oBACvC,OAAO,CAAC,GAAG,CAAC,+CAA+C,QAAQ,CAAC,IAAI,UAAU,MAAM,CAAC,QAAQ,QAAQ,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;oBACvJ,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC;iBAC5B;gBAED,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;gBAEnC,QAAQ,GAAG,QAAQ,IAAI,QAAQ,CAAC,QAAQ,KAAK,IAAI,CAAC;gBAElD,IAAI,UAAU,GAAG,QAAQ,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBAEzG,IAAI,QAAQ,CAAC,WAAW;oBACpB,GAAG,CAAC,YAAY,IAAI,YAAY,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,GAAG,UAAU,CAAC;qBAClH,IAAI,UAAU,CAAC,MAAM;oBACtB,GAAG,CAAC,YAAY,IAAI,YAAY,QAAQ,CAAC,IAAI,GAAG,GAAG,UAAU,CAAC;aACrE;SACJ;QAED,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC;IAChC,CAAC;IAEO,SAAS,CAAC,OAAY,EAAE,YAAY,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI;QACxD,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;YAC3B,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;SACvB;aAAM;YACH,IAAI,KAAK,GAAG,EAAE,CAAC;YACf,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE;gBAEjC,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;gBAElC,IAAI,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;gBAErE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACpB;YACD,IAAI,OAAO,CAAC,QAAQ,EAAE;gBAClB,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;aAC5B;YACD,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC;gBAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;;gBAClC,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACvC;IACL,CAAC;IAEO,eAAe,CAAC,IAAY;QAChC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE;YACzB,IAAI,GAAY,IAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAChD;QACD,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,KAAK,oBAAoB,EAAE;YAC3D,IAAI,GAAY,IAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAC/C;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,eAAe,CAAC,IAAY;QAChC,IAAI,IAAI,KAAK,OAAO;YAAE,OAAO,QAAQ,CAAC;QACtC,IAAI,IAAI,KAAK,UAAU;YAAE,OAAO,UAAU,CAAC;QAC3C,IAAI,IAAI,KAAK,oBAAoB;YAAE,OAAO,YAAY,CAAC;QACvD,IAAI,IAAI,KAAK,OAAO;YAAE,OAAO,OAAO,CAAC;QAErC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;YAC3B,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;YAE1C,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;gBACvB,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;aAClD;SACJ;aAAM,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YACnC,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YAE3C,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;gBACvB,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE;oBAC/B,IAAI,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBAClC,OAAO,UAAU,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;iBAC1F;qBAAM;oBACH,OAAO,mBAAmB,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;iBACjE;aACJ;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,YAAY,CAAC,MAAW,EAAE,GAAwC;QACtE,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC;QACtC,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,EAAE;YAC1B,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC;YACrC,IAAI,IAAI,GAAwB,GAAI,CAAC,IAAI,CAAC;YAC1C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBAC3B,IAAI,IAAI,CAAC,IAAI,IAAI,KAAK;oBAClB,OAAO,CAAC,GAAG,CAAC,uDAAuD,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAC1F,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,mBAAmB;aACpD;SACJ;aAAM,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,EAAE,EAAC,qDAAqD;YACvF,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,WAAW;gBAAE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC;;gBACrE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,QAAQ,CAAC;SACnD;QACD,QAAQ,MAAM,CAAC,MAAM,EAAE;YACnB,KAAK,WAAW;gBACZ,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,SAAS,CAAC;gBAC5C,MAAM;YACV,KAAK,SAAS;gBACV,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,OAAO,CAAC;gBAC1C,MAAM;SACb;QACD,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU;YAAE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,QAAQ,CAAC;QAC9F,IAAI,MAAM,CAAC,KAAK,KAAK,QAAQ;YAAE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC;IAC5E,CAAC;IAEO,cAAc,CAAC,MAAW,EAAE,GAAwG,EAAE,MAAuB;QACjK,IAAI,MAAM,CAAC,IAAI;YACX,KAAK,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,EAAE;gBACzB,IAAI,GAAG,CAAC,aAAa,KAAK,SAAS,EAAE;oBAEjC;;;;;;uBAMG;oBACH,MAAM,OAAO,GAAY,GAAG,CAAC,KAAM,CAAC,KAAK,CAAC,+EAA+E,CAAC,CAAC;oBAC3H,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,CAAC,GAAG,OAAO,CAAC;oBAE9D,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,CACtC,KAAK,EACL,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CACzD,CAAC;oBAEF,IAAG,YAAY,IAAI,IAAI,EAAE;wBACrB,SAAS,CAAC,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;qBAClE;oBAE2E,GAAI,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBAChH,eAAe,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;iBAExC;qBAAM,IAAI,GAAG,CAAC,aAAa,KAAK,YAAY,EAAE;oBAC3C,IAAI,OAAO,GAAY,GAAG,CAAC,KAAM,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;oBAC7F,IAAI,YAAY,GAAW,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;oBAE5D,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC;iBACnE;aACJ;QAEL,SAAS,eAAe,CAAC,aAAqB,EAAE,YAAoB;YAChE,IAAI,aAAa,IAAI,IAAI,EAAE;gBACvB,IAAI,SAAS,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACzC,IAAI,MAAM,IAAI,IAAI,EAAE;oBAChB,KAAK,IAAI,KAAK,IAAI,MAAM,EAAE;wBACtB,IAAI,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE;4BACrC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;yBAC5D;qBACJ;iBACJ;gBACD,IAAI,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,EAAC,kCAAkC;oBAC7C,GAAI,CAAC,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;iBAC3F;gBACD,IAAI,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAC,gCAAgC;oBACzC,GAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;iBACrF;aACJ;QACL,CAAC;IACL,CAAC;CAEJ;AA7oBD,wBA6oBC"} \ No newline at end of file diff --git a/scripts/tsgen/src/Parser.ts b/scripts/tsgen/src/Parser.ts index a7a847c82..c7b8df970 100644 --- a/scripts/tsgen/src/Parser.ts +++ b/scripts/tsgen/src/Parser.ts @@ -41,7 +41,7 @@ export class Parser { let ignored = []; - let result = '/// \n\n'; + let result = '// DO NOT EDIT THIS FILE! It was generated by running `npm run tsgen`\n/// \n\n'; result = result.concat(this.topLevel.reduce((out: string, obj: dom.TopLevelDeclaration) => { return out + dom.emit(obj); diff --git a/src/core/typedefs/GameConfig.js b/src/core/typedefs/GameConfig.js index 44827eb98..ef39143b1 100644 --- a/src/core/typedefs/GameConfig.js +++ b/src/core/typedefs/GameConfig.js @@ -12,7 +12,7 @@ * @property {string} [canvasStyle=null] - CSS styles to apply to the game canvas instead of Phasers default styles. * @property {boolean}[customEnvironment=false] - Is Phaser running under a custom (non-native web) environment? If so, set this to `true` to skip internal Feature detection. If `true` the `renderType` cannot be left as `AUTO`. * @property {CanvasRenderingContext2D} [context] - Provide your own Canvas Context for Phaser to use, instead of creating one. - * @property {(Phaser.Scene|Phaser.Scene[]|Phaser.Types.Scenes.SettingsConfig|Phaser.Types.Scenes.SettingsConfig[]|Phaser.Types.Scenes.CreateSceneFromObjectConfig|Phaser.Types.Scenes.CreateSceneFromObjectConfig[]|function|function[])} [scene=null] - A scene or scenes to add to the game. If several are given, the first is started; the remainder are started only if they have `{ active: true }`. See the `sceneConfig` argument in `Phaser.Scenes.SceneManager#add`. + * @property {(Phaser.Types.Scenes.SceneType|Phaser.Types.Scenes.SceneType[])} [scene=null] - A scene or scenes to add to the game. If several are given, the first is started; the remainder are started only if they have `{ active: true }`. See the `sceneConfig` argument in `Phaser.Scenes.SceneManager#add`. * @property {string[]} [seed] - Seed for the random number generator. * @property {string} [title=''] - The title of the game. Shown in the browser console. * @property {string} [url='https://phaser.io'] - The URL of the game. Shown in the browser console. diff --git a/src/scene/SceneManager.js b/src/scene/SceneManager.js index 8b92368f2..7880347f1 100644 --- a/src/scene/SceneManager.js +++ b/src/scene/SceneManager.js @@ -333,7 +333,7 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - A unique key used to reference the Scene, i.e. `MainMenu` or `Level1`. - * @param {(Phaser.Scene|Phaser.Types.Scenes.SettingsConfig|Phaser.Types.Scenes.CreateSceneFromObjectConfig|function)} sceneConfig - The config for the Scene + * @param {(Phaser.Types.Scenes.SceneType)} sceneConfig - The config for the Scene * @param {boolean} [autoStart=false] - If `true` the Scene will be started immediately after being added. * @param {object} [data] - Optional data object. This will be set as `Scene.settings.data` and passed to `Scene.init`, and `Scene.create`. * diff --git a/src/scene/ScenePlugin.js b/src/scene/ScenePlugin.js index b6b6cc0ca..20af705f7 100644 --- a/src/scene/ScenePlugin.js +++ b/src/scene/ScenePlugin.js @@ -444,7 +444,7 @@ var ScenePlugin = new Class({ * @since 3.0.0 * * @param {string} key - A unique key used to reference the Scene, i.e. `MainMenu` or `Level1`. - * @param {(Phaser.Scene|Phaser.Types.Scenes.SettingsConfig|Phaser.Types.Scenes.CreateSceneFromObjectConfig|function)} sceneConfig - The config for the Scene + * @param {(Phaser.Types.Scenes.SceneType)} sceneConfig - The config for the Scene * @param {boolean} [autoStart=false] - If `true` the Scene will be started immediately after being added. * @param {object} [data] - Optional data object. This will be set as `Scene.settings.data` and passed to `Scene.init`, and `Scene.create`. * diff --git a/src/scene/typedefs/SceneType.js b/src/scene/typedefs/SceneType.js new file mode 100644 index 000000000..eb0350dae --- /dev/null +++ b/src/scene/typedefs/SceneType.js @@ -0,0 +1,4 @@ +/** + * @typedef {(Phaser.Scene|Phaser.Types.Scenes.SettingsConfig|Phaser.Types.Scenes.CreateSceneFromObjectConfig|function)} Phaser.Types.Scenes.SceneType + * @since 3.18.0 + */ diff --git a/types/phaser.d.ts b/types/phaser.d.ts index 25567aec9..6b465b65f 100644 --- a/types/phaser.d.ts +++ b/types/phaser.d.ts @@ -1,3 +1,4 @@ +// DO NOT EDIT THIS FILE! It was generated by running `npm run tsgen` /// declare type CameraRotateCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number, angle: number)=>void; @@ -12,8 +13,6 @@ declare type EachContainerCallback = (item: any, ...args: any[])=>void; declare type LightForEach = (light: Phaser.GameObjects.Light)=>void; -declare type SceneType = Phaser.Scene | Phaser.Types.Scenes.SettingsConfig | Phaser.Types.Scenes.CreateSceneFromObjectConfig | Function; - /** * A custom function that will be responsible for wrapping the text. */ @@ -633,18 +632,6 @@ declare namespace Phaser { */ function Shuffle(items: G): G; - /** - * Smoothstep 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 SmoothStep(items: G, property: string, min: number, max: number, inc?: boolean): G; - /** * Smootherstep is a sigmoid-like interpolation and clamping function. * @@ -657,6 +644,18 @@ declare namespace Phaser { */ function SmootherStep(items: G, property: string, min: number, max: number, inc?: boolean): G; + /** + * Smoothstep 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 SmoothStep(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. @@ -2226,7 +2225,7 @@ declare namespace Phaser { * This can happen either as a result of an animation instance being added to the Animation Manager, * or the Animation Manager creating a new animation directly. */ - const ADD_ANIMATION: any; + const ADD_ANIMATION: string; /** * The Animation Complete Event. @@ -2253,7 +2252,7 @@ declare namespace Phaser { * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. */ - const ANIMATION_COMPLETE: any; + const ANIMATION_COMPLETE: string; /** * The Animation Complete Dynamic Key Event. @@ -2284,7 +2283,7 @@ declare namespace Phaser { * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. */ - const ANIMATION_COMPLETE_KEY: any; + const ANIMATION_COMPLETE_KEY: string; /** * The Animation Repeat Event. @@ -2308,7 +2307,7 @@ declare namespace Phaser { * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. */ - const ANIMATION_REPEAT: any; + const ANIMATION_REPEAT: string; /** * The Animation Restart Event. @@ -2330,7 +2329,7 @@ declare namespace Phaser { * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. */ - const ANIMATION_RESTART: any; + const ANIMATION_RESTART: string; /** * The Animation Start Event. @@ -2353,7 +2352,7 @@ declare namespace Phaser { * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. */ - const ANIMATION_START: any; + const ANIMATION_START: string; /** * The Animation Stop Event. @@ -2376,7 +2375,7 @@ declare namespace Phaser { * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. */ - const ANIMATION_STOP: any; + const ANIMATION_STOP: string; /** * The Animation Update Event. @@ -2403,7 +2402,7 @@ declare namespace Phaser { * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. */ - const ANIMATION_UPDATE: any; + const ANIMATION_UPDATE: string; /** * The Pause All Animations Event. @@ -2413,14 +2412,14 @@ declare namespace Phaser { * When this happens all current animations will stop updating, although it doesn't necessarily mean * that the game has paused as well. */ - const PAUSE_ALL: any; + const PAUSE_ALL: string; /** * The Remove Animation Event. * * This event is dispatched when an animation is removed from the global Animation Manager. */ - const REMOVE_ANIMATION: any; + const REMOVE_ANIMATION: string; /** * The Resume All Animations Event. @@ -2429,7 +2428,7 @@ declare namespace Phaser { * * When this happens all current animations will continue updating again. */ - const RESUME_ALL: any; + const RESUME_ALL: string; } @@ -2614,14 +2613,14 @@ declare namespace Phaser { * * This event is dispatched by any Cache that extends the BaseCache each time a new object is added to it. */ - const ADD: any; + const ADD: string; /** * The Cache Remove Event. * * This event is dispatched by any Cache that extends the BaseCache each time an object is removed from it. */ - const REMOVE: any; + const REMOVE: string; } @@ -2809,6 +2808,12 @@ declare namespace Phaser { */ renderList: Phaser.GameObjects.GameObject[]; + /** + * Is this Camera a Scene Camera? (which is the default), or a Camera + * belonging to a Texture? + */ + isSceneCamera: boolean; + /** * Adds the given Game Object to this cameras render list. * @@ -3017,8 +3022,9 @@ declare namespace Phaser { /** * Sets the Scene the Camera is bound to. * @param scene The Scene the camera is bound to. + * @param isSceneCamera Is this Camera being used for a Scene (true) or a Texture? (false) Default true. */ - setScene(scene: Phaser.Scene): this; + setScene(scene: Phaser.Scene, isSceneCamera?: boolean): this; /** * Set the position of where the Camera is looking within the game. @@ -3117,6 +3123,13 @@ declare namespace Phaser { */ protected update(time: number, delta: number): void; + /** + * Set if this Camera is being used as a Scene Camera, or a Texture + * Camera. + * @param value Is this being used as a Scene Camera, or a Texture camera? + */ + setIsSceneCamera(value: boolean): void; + /** * Destroys this Camera instance and its internal properties and references. * Once destroyed you cannot use this Camera again, even if re-added to a Camera Manager. @@ -4587,7 +4600,7 @@ declare namespace Phaser { * * This event is dispatched by a Camera instance when it is destroyed by the Camera Manager. */ - const DESTROY: any; + const DESTROY: string; /** * The Camera Fade In Complete Event. @@ -4596,7 +4609,7 @@ declare namespace Phaser { * * Listen to it from a Camera instance using `Camera.on('camerafadeincomplete', listener)`. */ - const FADE_IN_COMPLETE: any; + const FADE_IN_COMPLETE: string; /** * The Camera Fade In Start Event. @@ -4605,7 +4618,7 @@ declare namespace Phaser { * * Listen to it from a Camera instance using `Camera.on('camerafadeinstart', listener)`. */ - const FADE_IN_START: any; + const FADE_IN_START: string; /** * The Camera Fade Out Complete Event. @@ -4614,7 +4627,7 @@ declare namespace Phaser { * * Listen to it from a Camera instance using `Camera.on('camerafadeoutcomplete', listener)`. */ - const FADE_OUT_COMPLETE: any; + const FADE_OUT_COMPLETE: string; /** * The Camera Fade Out Start Event. @@ -4623,21 +4636,21 @@ declare namespace Phaser { * * Listen to it from a Camera instance using `Camera.on('camerafadeoutstart', listener)`. */ - const FADE_OUT_START: any; + const FADE_OUT_START: string; /** * The Camera Flash Complete Event. * * This event is dispatched by a Camera instance when the Flash Effect completes. */ - const FLASH_COMPLETE: any; + const FLASH_COMPLETE: string; /** * The Camera Flash Start Event. * * This event is dispatched by a Camera instance when the Flash Effect starts. */ - const FLASH_START: any; + const FLASH_START: string; /** * The Camera Follower Update Event. @@ -4648,21 +4661,21 @@ declare namespace Phaser { * * Listen to it from a Camera instance using: `camera.on('followupdate', listener)`. */ - const FOLLOW_UPDATE: any; + const FOLLOW_UPDATE: string; /** * The Camera Pan Complete Event. * * This event is dispatched by a Camera instance when the Pan Effect completes. */ - const PAN_COMPLETE: any; + const PAN_COMPLETE: string; /** * The Camera Pan Start Event. * * This event is dispatched by a Camera instance when the Pan Effect starts. */ - const PAN_START: any; + const PAN_START: string; /** * The Camera Post-Render Event. @@ -4672,7 +4685,7 @@ declare namespace Phaser { * * Listen to it from a Camera instance using: `camera.on('postrender', listener)`. */ - const POST_RENDER: any; + const POST_RENDER: string; /** * The Camera Pre-Render Event. @@ -4682,49 +4695,49 @@ declare namespace Phaser { * * Listen to it from a Camera instance using: `camera.on('prerender', listener)`. */ - const PRE_RENDER: any; + const PRE_RENDER: string; /** * The Camera Rotate Complete Event. * * This event is dispatched by a Camera instance when the Rotate Effect completes. */ - const ROTATE_COMPLETE: any; + const ROTATE_COMPLETE: string; /** * The Camera Rotate Start Event. * * This event is dispatched by a Camera instance when the Rotate Effect starts. */ - const ROTATE_START: any; + const ROTATE_START: string; /** * The Camera Shake Complete Event. * * This event is dispatched by a Camera instance when the Shake Effect completes. */ - const SHAKE_COMPLETE: any; + const SHAKE_COMPLETE: string; /** * The Camera Shake Start Event. * * This event is dispatched by a Camera instance when the Shake Effect starts. */ - const SHAKE_START: any; + const SHAKE_START: string; /** * The Camera Zoom Complete Event. * * This event is dispatched by a Camera instance when the Zoom Effect completes. */ - const ZOOM_COMPLETE: any; + const ZOOM_COMPLETE: string; /** * The Camera Zoom Start Event. * * This event is dispatched by a Camera instance when the Zoom Effect starts. */ - const ZOOM_START: any; + const ZOOM_START: string; } @@ -5820,6 +5833,148 @@ 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * The Game Resume Event. + * + * This event is dispatched when the game loop leaves a paused state and resumes running. + */ + const RESUME: string; + + /** + * 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: string; + + /** + * 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: string; + + } + /** * 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. @@ -6163,148 +6318,6 @@ 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 { @@ -6869,135 +6882,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; - - } - /** * 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. @@ -7283,6 +7167,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; + + } + } namespace Data { @@ -7548,7 +7561,7 @@ declare namespace Phaser { * This event is dispatched for all items that change in the Data Manager. * To listen for the change of a specific item, use the `CHANGE_DATA_KEY_EVENT` event. */ - const CHANGE_DATA: any; + const CHANGE_DATA: string; /** * The Change Data Key Event. @@ -7560,14 +7573,14 @@ declare namespace Phaser { * where `key` is the unique string key of the data item. For example, if you have a data item stored called `gold` * then you can listen for `sprite.data.on('changedata-gold')`. */ - const CHANGE_DATA_KEY: any; + const CHANGE_DATA_KEY: string; /** * The Data Manager Destroy Event. * * The Data Manager will listen for the destroy event from its parent, and then close itself down. */ - const DESTROY: any; + const DESTROY: string; /** * The Remove Data Event. @@ -7577,7 +7590,7 @@ declare namespace Phaser { * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for * the removal of a data item on a Game Object you would use: `sprite.data.on('removedata', listener)`. */ - const REMOVE_DATA: any; + const REMOVE_DATA: string; /** * The Set Data Event. @@ -7587,7 +7600,7 @@ declare namespace Phaser { * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for * the addition of a new data item on a Game Object you would use: `sprite.data.on('setdata', listener)`. */ - const SET_DATA: any; + const SET_DATA: string; } @@ -8002,241 +8015,6 @@ 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. @@ -9038,6 +8816,16 @@ 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. @@ -9066,16 +8854,6 @@ 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) @@ -9102,6 +8880,14 @@ 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. * @@ -9132,14 +8918,6 @@ 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. @@ -9149,6 +8927,160 @@ 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. @@ -9182,84 +9114,43 @@ declare namespace Phaser { class BitmapMask { /** * - * @param scene The Scene which this Bitmap Mask will be used in. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + * @param scene The Scene to which this mask is being added. + * @param maskObject The Game Object that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. + * @param x If creating a Game Object, the horizontal position in the world. + * @param y If creating a Game Object, the vertical position in the world. + * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. + * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. */ - constructor(scene: Phaser.Scene, renderable: Phaser.GameObjects.GameObject); + constructor(scene: Phaser.Scene, maskObject?: Phaser.GameObjects.GameObject, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame); /** - * A reference to either the Canvas or WebGL Renderer that this Mask is using. - */ - renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; - - /** - * A renderable Game Object that uses a texture, such as a Sprite. + * The Game Object that is used as the mask. Must use a texture, such as a Sprite. */ bitmapMask: Phaser.GameObjects.GameObject; - /** - * The texture used for the masks framebuffer. - */ - maskTexture: WebGLTexture; - - /** - * The texture used for the main framebuffer. - */ - mainTexture: WebGLTexture; - - /** - * Whether the Bitmap Mask is dirty and needs to be updated. - */ - dirty: boolean; - - /** - * The framebuffer to which a masked Game Object is rendered. - */ - mainFramebuffer: WebGLFramebuffer; - - /** - * The framebuffer to which the Bitmap Mask's masking Game Object is rendered. - */ - maskFramebuffer: WebGLFramebuffer; - /** * Whether to invert the masks alpha. * * If `true`, the alpha of the masking pixel will be inverted before it's multiplied with the masked pixel. + * * Essentially, this means that a masked area will be visible only if the corresponding area in the mask is invisible. */ invertAlpha: boolean; /** - * Is this mask a stencil mask? + * Is this mask a stencil mask? This is false by default and should not be changed. */ readonly isStencil: boolean; /** - * The Scene which this Bitmap Mask will be used in. - */ - scene: Phaser.Scene; - - /** - * Creates the WebGL Texture2D objects and Framebuffers required for this - * mask. If this mask has already been created, then `clearMask` is called first. - */ - createMask(): void; - - /** - * Deletes the `mainTexture` and `maskTexture` WebGL Textures and deletes - * the `mainFramebuffer` and `maskFramebuffer` too, nulling all references. + * Sets a new Game Object for this Bitmap Mask to use. * - * This is called when this mask is destroyed, or if you try to creat a new - * mask from this object when one is already set. + * The Game Object must have a texture, such as a Sprite. + * + * You can update the source Game Object being used as the mask as often as you like. + * @param maskObject The Game Object that will be used as the mask. Must have a texture, such as a Sprite. */ - clearMask(): void; - - /** - * Sets a new masking Game Object for the Bitmap Mask. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - setBitmap(renderable: Phaser.GameObjects.GameObject): void; + setBitmap(maskObject: Phaser.GameObjects.GameObject): void; /** * Prepares the WebGL Renderer to render a Game Object with this mask applied. @@ -9276,8 +9167,10 @@ declare namespace Phaser { * * This resets the previously bound framebuffer and switches the WebGL Renderer to the Bitmap Mask Pipeline, which uses a special fragment shader to apply the masking effect. * @param renderer The WebGL Renderer to clean up. + * @param camera The Camera to render to. + * @param renderTarget Optional WebGL RenderTarget. */ - postRenderWebGL(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer): void; + postRenderWebGL(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer, camera: Phaser.Cameras.Scene2D.Camera, renderTarget?: Phaser.Renderer.WebGL.RenderTarget): void; /** * This is a NOOP method. Bitmap Masks are not supported by the Canvas Renderer. @@ -9410,6 +9303,87 @@ 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. * @@ -9671,1721 +9645,6 @@ 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 | null; - - /** - * 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 | null; - - /** - * 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. - * @param fromScene `True` if this Game Object is being destroyed by the Scene, `false` if not. Default false. - */ - destroy(fromScene?: boolean): 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; - - /** - * Static method called directly by the Game Object creator functions. - * With this method you can register a custom GameObject factory in the GameObjectCreator, - * providing a name (`factoryType`) and the constructor (`factoryFunction`) in order - * to be called when you invoke Phaser.Scene.make[ factoryType ] method. - * @param factoryType The key of the factory that you will use to call to Phaser.Scene.make[ factoryType ] method. - * @param factoryFunction The constructor function to be called when you invoke to the Phaser.Scene.make method. - */ - static register(factoryType: string, factoryFunction: Function): void; - - /** - * Static method called directly by the Game Object Creator functions. - * - * With this method you can remove a custom Game Object Creator that has been previously - * registered in the Game Object Creator. Pass in its `factoryType` in order to remove it. - * @param factoryType The key of the factory that you want to remove from the GameObjectCreator. - */ - static remove(factoryType: string): void; - - /** - * 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: Phaser.Types.GameObjects.Sprite.SpriteConfig, 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: Phaser.Types.GameObjects.Container.ContainerConfig, 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: Phaser.Types.GameObjects.Graphics.Options, 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: Phaser.Types.GameObjects.Sprite.SpriteConfig, 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: Phaser.Types.GameObjects.Sprite.SpriteConfig, 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: Phaser.Types.GameObjects.Mesh.MeshConfig, 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: Phaser.Types.GameObjects.Particles.ParticleEmitterManagerConfig, 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: Phaser.Types.GameObjects.Rope.RopeConfig, 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: Phaser.Types.GameObjects.Shader.ShaderConfig, 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: Phaser.Types.GameObjects.Video.VideoConfig, 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: Phaser.Types.GameObjects.Zone.ZoneConfig): 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; - - /** - * Creates a new TweenChain object and returns it, without adding it to the Tween Manager. - * - * Note: This method will only be available if Tweens have been built into Phaser. - * @param config The TweenChain configuration. - */ - tweenchain(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.TweenChain; - - } - - /** - * 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[] | Phaser.Types.GameObjects.Group.GroupCreateConfig, 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 color 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; - - /** - * Creates a new TweenChain object and adds it to the Tween Manager. - * - * Note: This method will only be available if Tweens have been built into Phaser. - * @param config The TweenChain configuration. - */ - tweenchain(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.TweenChain; - - } - - /** - * 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): Phaser.Types.GameObjects.BitmapText.BitmapFontData; - - /** - * 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. * @@ -11551,6 +9810,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -11565,7 +9825,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -11574,6 +9834,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -11587,9 +9848,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -11658,7 +9919,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -11931,17 +10192,19 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * The Frame has to belong to the current Texture being used. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * It can be either a string or an index. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture. + * @param frame The name or index of the frame within the Texture, or a Frame instance. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -12242,6 +10505,72 @@ 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): Phaser.Types.GameObjects.BitmapText.BitmapFontData; + + } + /** * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. * @@ -12691,6 +11020,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -12705,7 +11035,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -12714,6 +11044,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -12727,9 +11058,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -12798,7 +11129,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -13071,17 +11402,19 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * The Frame has to belong to the current Texture being used. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * It can be either a string or an index. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture. + * @param frame The name or index of the frame within the Texture, or a Frame instance. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -13535,6 +11868,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -13549,7 +11883,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -13558,6 +11892,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -13571,9 +11906,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -13642,7 +11977,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -13937,17 +12272,19 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * The Frame has to belong to the current Texture being used. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * It can be either a string or an index. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture. + * @param frame The name or index of the frame within the Texture, or a Frame instance. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** * A property indicating that a Game Object has this component. @@ -14312,6 +12649,21 @@ 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. @@ -14401,6 +12753,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -14415,7 +12768,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. * @@ -14423,6 +12776,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -14436,9 +12790,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; } /** @@ -14582,52 +12936,6 @@ declare namespace Phaser { setDepth(value: number): this; } - /** - * Provides methods used for setting the FX values of a Game Object. - * Should be applied as a mixin and not used directly. - */ - interface FX { - /** - * The amount of extra padding to be applied to this Game Object - * when it is being rendered by a SpriteFX Pipeline. - * - * Lots of FX require additional spacing added to the texture the - * Game Object uses, for example a glow or shadow effect, and this - * method allows you to control how much extra padding is included - * in addition to the texture size. - */ - fxPadding: number; - /** - * Sets the amount of extra padding to be applied to this Game Object - * when it is being rendered by a SpriteFX Pipeline. - * - * Lots of FX require additional spacing added to the texture the - * Game Object uses, for example a glow or shadow effect, and this - * method allows you to control how much extra padding is included - * in addition to the texture size. - * @param padding The amount of padding to add to the texture. Default 0. - */ - setFXPadding(padding?: number): this; - /** - * This callback is invoked when this Game Object is copied by a SpriteFX Pipeline. - * - * This happens when the pipeline uses its `copySprite` method. - * - * It's invoked prior to the copy, allowing you to set shader uniforms, etc on the pipeline. - * @param pipeline The SpriteFX Pipeline that invoked this callback. - */ - onFXCopy(pipeline: Phaser.Renderer.WebGL.Pipelines.SpriteFXPipeline): void; - /** - * This callback is invoked when this Game Object is rendered by a SpriteFX Pipeline. - * - * This happens when the pipeline uses its `drawSprite` method. - * - * It's invoked prior to the draw, allowing you to set shader uniforms, etc on the pipeline. - * @param pipeline The SpriteFX Pipeline that invoked this callback. - */ - onFX(pipeline: Phaser.Renderer.WebGL.Pipelines.SpriteFXPipeline): void; - } - /** * Provides methods used for visually flipping a Game Object. * Should be applied as a mixin and not used directly. @@ -14691,6 +12999,52 @@ declare namespace Phaser { resetFlip(): this; } + /** + * Provides methods used for setting the FX values of a Game Object. + * Should be applied as a mixin and not used directly. + */ + interface FX { + /** + * The amount of extra padding to be applied to this Game Object + * when it is being rendered by a SpriteFX Pipeline. + * + * Lots of FX require additional spacing added to the texture the + * Game Object uses, for example a glow or shadow effect, and this + * method allows you to control how much extra padding is included + * in addition to the texture size. + */ + fxPadding: number; + /** + * Sets the amount of extra padding to be applied to this Game Object + * when it is being rendered by a SpriteFX Pipeline. + * + * Lots of FX require additional spacing added to the texture the + * Game Object uses, for example a glow or shadow effect, and this + * method allows you to control how much extra padding is included + * in addition to the texture size. + * @param padding The amount of padding to add to the texture. Default 0. + */ + setFXPadding(padding?: number): this; + /** + * This callback is invoked when this Game Object is copied by a SpriteFX Pipeline. + * + * This happens when the pipeline uses its `copySprite` method. + * + * It's invoked prior to the copy, allowing you to set shader uniforms, etc on the pipeline. + * @param pipeline The SpriteFX Pipeline that invoked this callback. + */ + onFXCopy(pipeline: Phaser.Renderer.WebGL.Pipelines.SpriteFXPipeline): void; + /** + * This callback is invoked when this Game Object is rendered by a SpriteFX Pipeline. + * + * This happens when the pipeline uses its `drawSprite` method. + * + * It's invoked prior to the draw, allowing you to set shader uniforms, etc on the pipeline. + * @param pipeline The SpriteFX Pipeline that invoked this callback. + */ + onFX(pipeline: Phaser.Renderer.WebGL.Pipelines.SpriteFXPipeline): void; + } + /** * Provides methods used for obtaining the bounds of a Game Object. * Should be applied as a mixin and not used directly. @@ -14807,7 +13161,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -15220,17 +13574,19 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * The Frame has to belong to the current Texture being used. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * It can be either a string or an index. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture. + * @param frame The name or index of the frame within the Texture, or a Frame instance. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; } /** @@ -15290,17 +13646,19 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * The Frame has to belong to the current Texture being used. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * It can be either a string or an index. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture. + * @param frame The name or index of the frame within the Texture, or a Frame instance. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; } /** @@ -15605,6 +13963,11 @@ declare namespace Phaser { */ decomposedMatrix: object; + /** + * The temporary quad value cache. + */ + quad: Float32Array; + /** * The Scale X value. */ @@ -15813,6 +14176,20 @@ declare namespace Phaser { */ applyInverse(x: number, y: number, output?: Phaser.Math.Vector2): Phaser.Math.Vector2; + /** + * Performs the 8 calculations required to create the vertices of + * a quad based on this matrix and the given x/y/xw/yh values. + * + * The result is stored in `TransformMatrix.quad`, which is returned + * from this method. + * @param x The x value. + * @param y The y value. + * @param xw The xw value. + * @param yh The yh value. + * @param roundPixels Pass the results via Math.round? + */ + setQuad(x: number, y: number, xw: number, yh: number, roundPixels: boolean): number; + /** * Returns the X component of this matrix multiplied by the given values. * This is the same as `x * a + y * c + e`. @@ -16446,6 +14823,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -16460,7 +14838,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -16469,6 +14847,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -16482,9 +14861,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The native (un-scaled) width of this Game Object. @@ -16613,7 +14992,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -16949,6 +15328,65 @@ 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. * @@ -17421,6 +15859,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -17435,7 +15874,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -17444,6 +15883,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -17457,9 +15897,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -17809,7 +16249,7 @@ declare namespace Phaser { * * Listen for it on a Game Object instance using `GameObject.on('addedtoscene', listener)`. */ - const ADDED_TO_SCENE: any; + const ADDED_TO_SCENE: string; /** * The Game Object Destroy Event. @@ -17818,7 +16258,7 @@ declare namespace Phaser { * * Listen for it on a Game Object instance using `GameObject.on('destroy', listener)`. */ - const DESTROY: any; + const DESTROY: string; /** * The Game Object Removed from Scene Event. @@ -17827,7 +16267,7 @@ declare namespace Phaser { * * Listen for it on a Game Object instance using `GameObject.on('removedfromscene', listener)`. */ - const REMOVED_FROM_SCENE: any; + const REMOVED_FROM_SCENE: string; /** * The Video Game Object Complete Event. @@ -17843,7 +16283,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('complete', listener)`. */ - const VIDEO_COMPLETE: any; + const VIDEO_COMPLETE: string; /** * The Video Game Object Created Event. @@ -17854,7 +16294,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('created', listener)`. */ - const VIDEO_CREATED: any; + const VIDEO_CREATED: string; /** * The Video Game Object Error Event. @@ -17863,7 +16303,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('error', listener)`. */ - const VIDEO_ERROR: any; + const VIDEO_ERROR: string; /** * The Video Game Object Loop Event. @@ -17879,7 +16319,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('loop', listener)`. */ - const VIDEO_LOOP: any; + const VIDEO_LOOP: string; /** * The Video Game Object Play Event. @@ -17891,7 +16331,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('play', listener)`. */ - const VIDEO_PLAY: any; + const VIDEO_PLAY: string; /** * The Video Game Object Seeked Event. @@ -17900,7 +16340,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('seeked', listener)`. */ - const VIDEO_SEEKED: any; + const VIDEO_SEEKED: string; /** * The Video Game Object Seeking Event. @@ -17910,7 +16350,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('seeking', listener)`. */ - const VIDEO_SEEKING: any; + const VIDEO_SEEKING: string; /** * The Video Game Object Stopped Event. @@ -17920,7 +16360,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('stop', listener)`. */ - const VIDEO_STOP: any; + const VIDEO_STOP: string; /** * The Video Game Object Timeout Event. @@ -17930,7 +16370,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('timeout', listener)`. */ - const VIDEO_TIMEOUT: any; + const VIDEO_TIMEOUT: string; /** * The Video Game Object Unlocked Event. @@ -17940,7 +16380,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('unlocked', listener)`. */ - const VIDEO_UNLOCKED: any; + const VIDEO_UNLOCKED: string; } @@ -18030,6 +16470,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -18044,7 +16485,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -18053,6 +16494,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -18066,9 +16508,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -18374,17 +16816,19 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * The Frame has to belong to the current Texture being used. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * It can be either a string or an index. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture. + * @param frame The name or index of the frame within the Texture, or a Frame instance. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -18685,6 +17129,1568 @@ 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 | null; + + /** + * 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 | null; + + /** + * 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. + * @param fromScene `True` if this Game Object is being destroyed by the Scene, `false` if not. Default false. + */ + destroy(fromScene?: boolean): 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: Phaser.Types.GameObjects.Sprite.SpriteConfig, 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: Phaser.Types.GameObjects.Container.ContainerConfig, 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; + + /** + * Static method called directly by the Game Object creator functions. + * With this method you can register a custom GameObject factory in the GameObjectCreator, + * providing a name (`factoryType`) and the constructor (`factoryFunction`) in order + * to be called when you invoke Phaser.Scene.make[ factoryType ] method. + * @param factoryType The key of the factory that you will use to call to Phaser.Scene.make[ factoryType ] method. + * @param factoryFunction The constructor function to be called when you invoke to the Phaser.Scene.make method. + */ + static register(factoryType: string, factoryFunction: Function): void; + + /** + * Static method called directly by the Game Object Creator functions. + * + * With this method you can remove a custom Game Object Creator that has been previously + * registered in the Game Object Creator. Pass in its `factoryType` in order to remove it. + * @param factoryType The key of the factory that you want to remove from the GameObjectCreator. + */ + static remove(factoryType: string): void; + + /** + * 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: Phaser.Types.GameObjects.Graphics.Options, 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: Phaser.Types.GameObjects.Sprite.SpriteConfig, 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: Phaser.Types.GameObjects.Sprite.SpriteConfig, 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: Phaser.Types.GameObjects.Mesh.MeshConfig, 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: Phaser.Types.GameObjects.Particles.ParticleEmitterManagerConfig, 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: Phaser.Types.GameObjects.Rope.RopeConfig, 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: Phaser.Types.GameObjects.Shader.ShaderConfig, 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: Phaser.Types.GameObjects.Video.VideoConfig, 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: Phaser.Types.GameObjects.Zone.ZoneConfig): 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; + + /** + * Creates a new TweenChain object and returns it, without adding it to the Tween Manager. + * + * Note: This method will only be available if Tweens have been built into Phaser. + * @param config The TweenChain configuration. + */ + tweenchain(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.TweenChain; + + } + + /** + * 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; + + /** + * A Bitmap Mask combines the alpha (opacity) of a masked pixel with the alpha of another pixel. + * Unlike the Geometry Mask, which is a clipping path, a Bitmap Mask behaves like an alpha mask, + * not a clipping path. It is only available when using the WebGL Renderer. + * + * A Bitmap Mask can use any Game Object to determine the alpha of each pixel of the masked Game Object(s). + * For any given point of a masked Game Object's texture, the pixel's alpha will be multiplied by the alpha + * of the pixel at the same position in the Bitmap Mask's Game Object. The color of the pixel from the + * Bitmap Mask doesn't matter. + * + * For example, if a pure blue pixel with an alpha of 0.95 is masked with a pure red pixel with an + * alpha of 0.5, the resulting pixel will be pure blue with an alpha of 0.475. Naturally, this means + * that a pixel in the mask with an alpha of 0 will hide the corresponding pixel in all masked Game Objects + * A pixel with an alpha of 1 in the masked Game Object will receive the same alpha as the + * corresponding pixel in the mask. + * + * Note: You cannot combine Bitmap Masks and Blend Modes on the same Game Object. You can, however, + * combine Geometry Masks and Blend Modes together. + * + * The Bitmap Mask's location matches the location of its Game Object, not the location of the + * masked objects. Moving or transforming the underlying Game Object will change the mask + * (and affect the visibility of any masked objects), whereas moving or transforming a masked object + * will not affect the mask. + * + * The Bitmap Mask will not render its Game Object by itself. If the Game Object is not in a + * Scene's display list, it will only be used for the mask and its full texture will not be directly + * visible. Adding the underlying Game Object to a Scene will not cause any problems - it will + * render as a normal Game Object and will also serve as a mask. + * @param maskObject The Game Object that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. + * @param x If creating a Game Object, the horizontal position in the world. + * @param y If creating a Game Object, the vertical position in the world. + * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. + * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. + */ + bitmapMask(maskObject?: Phaser.GameObjects.GameObject, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; + + /** + * 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[] | Phaser.Types.GameObjects.Group.GroupCreateConfig, 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 color 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; + + /** + * Creates a new TweenChain object and adds it to the Tween Manager. + * + * Note: This method will only be available if Tweens have been built into Phaser. + * @param config The TweenChain configuration. + */ + tweenchain(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.TweenChain; + + } + + /** + * 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 @@ -19256,6 +19262,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -19270,7 +19277,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -19279,6 +19286,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -19292,9 +19300,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -19363,7 +19371,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -20407,6 +20415,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -20421,7 +20430,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -20430,6 +20439,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -20443,9 +20453,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -20699,7 +20709,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -21088,17 +21098,19 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * The Frame has to belong to the current Texture being used. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * It can be either a string or an index. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture. + * @param frame The name or index of the frame within the Texture, or a Frame instance. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -21871,6 +21883,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -21885,7 +21898,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -21894,6 +21907,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -21907,9 +21921,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -21978,7 +21992,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -23272,6 +23286,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -23286,7 +23301,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -23295,6 +23310,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -23308,9 +23324,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -23379,7 +23395,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -23615,17 +23631,19 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * The Frame has to belong to the current Texture being used. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * It can be either a string or an index. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture. + * @param frame The name or index of the frame within the Texture, or a Frame instance. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** * A property indicating that a Game Object has this component. @@ -23882,6 +23900,1009 @@ declare namespace Phaser { } + /** + * TODO + */ + class NineSlice extends Phaser.GameObjects.RenderTexture implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Crop, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.FX, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Tint, 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 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. + */ + constructor(scene: Phaser.Scene, x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | 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. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + */ + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: 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; + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: 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: + * + * * NORMAL + * * 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 | 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: + * + * * NORMAL + * * 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, a CONST or a number. + */ + setBlendMode(value: string | Phaser.BlendModes | number): this; + + /** + * 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; + + /** + * 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; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. + * @param width The width of the crop rectangle in pixels. + * @param height The height of the crop rectangle in pixels. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + + /** + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. + * + * 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. Ensure this value is only ever a number data-type. + */ + setDepth(value: number): this; + + /** + * The horizontally flipped state of the Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + */ + flipX: boolean; + + /** + * The vertically flipped state of the Game Object. + * + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlipX(value: boolean): this; + + /** + * Sets the vertical flipped state of this Game Object. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlipY(value: boolean): this; + + /** + * Sets the horizontal and vertical flipped state of this Game Object. + * + * A Game Object that is flipped will render inversed on the flipped axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlip(x: boolean, y: boolean): this; + + /** + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + */ + resetFlip(): this; + + /** + * The amount of extra padding to be applied to this Game Object + * when it is being rendered by a SpriteFX Pipeline. + * + * Lots of FX require additional spacing added to the texture the + * Game Object uses, for example a glow or shadow effect, and this + * method allows you to control how much extra padding is included + * in addition to the texture size. + */ + fxPadding: number; + + /** + * Sets the amount of extra padding to be applied to this Game Object + * when it is being rendered by a SpriteFX Pipeline. + * + * Lots of FX require additional spacing added to the texture the + * Game Object uses, for example a glow or shadow effect, and this + * method allows you to control how much extra padding is included + * in addition to the texture size. + * @param padding The amount of padding to add to the texture. Default 0. + */ + setFXPadding(padding?: number): this; + + /** + * This callback is invoked when this Game Object is copied by a SpriteFX Pipeline. + * + * This happens when the pipeline uses its `copySprite` method. + * + * It's invoked prior to the copy, allowing you to set shader uniforms, etc on the pipeline. + * @param pipeline The SpriteFX Pipeline that invoked this callback. + */ + onFXCopy(pipeline: Phaser.Renderer.WebGL.Pipelines.SpriteFXPipeline): void; + + /** + * This callback is invoked when this Game Object is rendered by a SpriteFX Pipeline. + * + * This happens when the pipeline uses its `drawSprite` method. + * + * It's invoked prior to the draw, allowing you to set shader uniforms, etc on the pipeline. + * @param pipeline The SpriteFX Pipeline that invoked this callback. + */ + onFX(pipeline: Phaser.Renderer.WebGL.Pipelines.SpriteFXPipeline): void; + + /** + * 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 texture-based 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, or any kind of Shape Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): 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. + */ + postPipelines: 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 set 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 tint value being applied to the top-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + */ + tintTopLeft: number; + + /** + * The tint value being applied to the top-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + */ + tintTopRight: number; + + /** + * The tint value being applied to the bottom-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + */ + tintBottomLeft: number; + + /** + * The tint value being applied to the bottom-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + */ + tintBottomRight: number; + + /** + * The tint fill mode. + * + * `false` = An additive tint (the default), where vertices colors are blended with the texture. + * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. + */ + tintFill: boolean; + + /** + * Clears all tint values associated with this Game Object. + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. + */ + clearTint(): this; + + /** + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The tint value being applied to the whole of the Game Object. + * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value. + */ + tint: number; + + /** + * Does this Game Object have a tint applied? + * + * It checks to see if the 4 tint properties are set to the value 0xffffff + * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. + */ + readonly isTinted: boolean; + + /** + * A property indicating that a Game Object has this component. + */ + readonly hasTransformComponent: boolean; + + /** + * 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; + + } + namespace Particles { /** * A Particle Emitter property. @@ -24960,6 +25981,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -24973,9 +25995,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The Mask this Game Object is using during render. @@ -25017,7 +26039,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -25314,7 +26336,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -25909,6 +26931,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -25923,7 +26946,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -25932,6 +26955,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -25945,9 +26969,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -26201,7 +27225,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -26590,17 +27614,19 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * The Frame has to belong to the current Texture being used. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * It can be either a string or an index. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture. + * @param frame The name or index of the frame within the Texture, or a Frame instance. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -27062,6 +28088,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -27076,7 +28103,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -27085,6 +28112,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -27098,9 +28126,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -27247,7 +28275,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -27681,6 +28709,17 @@ declare namespace Phaser { */ textureManager: Phaser.Textures.TextureManager; + /** + * Internal Image Game Object used as a Stamp within this Render Texture. + */ + stamp: Phaser.GameObjects.Image; + + /** + * This flag is set to 'true' during `beginDraw` and reset to 'false` in `endDraw`, + * allowing you to determine if this Render Texture is batch drawing, or not. + */ + readonly isDrawing: boolean; + /** * The tint of the Render Texture when rendered. */ @@ -27754,7 +28793,7 @@ declare namespace Phaser { /** * If you are planning on using this Render Texture as a base texture for Sprite * Game Objects, then you should call this method with a value of `true` before - * calling drawing anything to it, otherwise you will get inverted frames in WebGL. + * drawing anything to it, otherwise you will get inverted frames in WebGL. * @param value Is this Render Target being used as a Sprite Texture, or not? */ setIsSpriteTexture(value: boolean): this; @@ -27966,22 +29005,32 @@ declare namespace Phaser { drawFrame(key: string, frame?: string | number, x?: number, y?: number, alpha?: number, tint?: number): this; /** - * Takes the given Texture Frame and draws it to this Render Texture - * as a fill pattern, i.e. in a grid-layout based on the frame dimensions. + * Resets the internal Stamp object, ready for drawing. + * @param alpha The alpha to use. Default 1. + * @param tint WebGL only. The tint color to use. Default 0xffffff. + */ + resetStamp(alpha?: number, tint?: number): Phaser.GameObjects.Image; + + /** + * Takes the given Texture Frame and draws it to this Render Texture as a fill pattern, + * i.e. in a grid-layout based on the frame dimensions. * * Textures are referenced by their string-based keys, as stored in the Texture Manager. * * ```javascript * var rt = this.add.renderTexture(0, 0, 800, 600); - * rt.fillFrame(key, frame); + * + * rt.repeat(key, frame); * ``` * - * You can optionally provide a position, alpha and tint value to apply to the frames - * before they are drawn. The position controls the offset of the first frame to be drawn - * and can be negative if required. + * You can optionally provide a position, width, height, alpha and tint value to apply to + * the frames before they are drawn. The position controls the top-left where the repeating + * fill will start from. The width and height control the size of the filled area. * - * Calling this method will cause a batch flush, so if you've got a stack of things to draw - * in a tight loop, try using the `draw` method instead. + * The position can be negative if required, but the dimensions cannot. + * + * Calling this method will cause a batch flush by default. Use the `skipBatch` argument + * to disable this, if this call is part of a larger batch draw. * * If you are planning on using this Render Texture as a base texture for Sprite * Game Objects, then you should set `RenderTexture.isSpriteTexture = true` before @@ -27990,10 +29039,13 @@ declare namespace Phaser { * @param frame The name or index of the frame within the Texture. Set to `null` to skip this argument if not required. * @param x The x position to start drawing the frames from (can be negative to offset). Default 0. * @param y The y position to start drawing the frames from (can be negative to offset). Default 0. - * @param alpha The alpha to use. If not specified it uses the `globalAlpha` property. - * @param tint WebGL only. The tint color to use. If not specified it uses the `globalTint` property. + * @param width The width of the area to repeat the frame within. Defaults to the width of this Render Texture. + * @param height The height of the area to repeat the frame within. Defaults to the height of this Render Texture. + * @param alpha The alpha to use. Defaults to 1, no alpha. Default 1. + * @param tint WebGL only. The tint color to use. Leave as undefined, or 0xffffff to have no tint. Default 0xffffff. + * @param skipBatch Skip beginning and ending a batch with this call. Use if this is part of a bigger batched draw. Default false. */ - fillFrame(key: string, frame?: string | number, x?: number, y?: number, alpha?: number, tint?: number): this; + repeat(key: string, frame?: string | number, x?: number, y?: number, width?: number, height?: number, alpha?: number, tint?: number, skipBatch?: boolean): this; /** * Use this method if you need to batch draw a large number of Game Objects to @@ -28001,9 +29053,11 @@ declare namespace Phaser { * * This method starts the beginning of a batched draw. * - * It is faster than calling `draw`, but you must be very careful to manage the - * flow of code and remember to call `endDraw()`. If you don't need to draw large - * numbers of objects it's much safer and easier to use the `draw` method instead. + * Batch drawing is faster than calling `draw`, but you must be very careful to manage the + * flow of code and remember to call `endDraw()` when you're finished. + * + * If you don't need to draw large numbers of objects it's much safer and easier + * to use the `draw` method instead. * * The flow should be: * @@ -28022,7 +29076,10 @@ declare namespace Phaser { * * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you * have started a batch. Also, be very careful not to destroy this Render Texture while the - * batch is still open, or call `beginDraw` again. + * batch is still open. + * + * You can use the `RenderTexture.isDrawing` boolean property to tell if a batch is + * currently open, or not. */ beginDraw(): this; @@ -28155,11 +29212,13 @@ declare namespace Phaser { /** * Use this method to finish batch drawing to this Render Texture. * - * Never call this method without first calling `beginDraw`. + * Calling this method without first calling `beginDraw` will have no effect. * - * It is faster than calling `draw`, but you must be very careful to manage the - * flow of code and remember to call `endDraw()`. If you don't need to draw large - * numbers of objects it's much safer and easier to use the `draw` method instead. + * Batch drawing is faster than calling `draw`, but you must be very careful to manage the + * flow of code and remember to call `endDraw()` when you're finished. + * + * If you don't need to draw large numbers of objects it's much safer and easier + * to use the `draw` method instead. * * The flow should be: * @@ -28178,7 +29237,10 @@ declare namespace Phaser { * * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you * have started a batch. Also, be very careful not to destroy this Render Texture while the - * batch is still open, or call `beginDraw` again. + * batch is still open. + * + * You can use the `RenderTexture.isDrawing` boolean property to tell if a batch is + * currently open, or not. * @param erase Draws all objects in this batch using a blend mode of ERASE. This has the effect of erasing any filled pixels in the objects being drawn. Default false. */ endDraw(erase?: boolean): this; @@ -28300,6 +29362,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -28314,7 +29377,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -28323,6 +29386,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -28336,9 +29400,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The native (un-scaled) width of this Game Object. @@ -28673,7 +29737,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -29602,6 +30666,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -29616,7 +30681,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -29625,6 +30690,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -29638,9 +30704,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -29755,7 +30821,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -29991,17 +31057,19 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * The Frame has to belong to the current Texture being used. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * It can be either a string or an index. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture. + * @param frame The name or index of the frame within the Texture, or a Frame instance. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** * A property indicating that a Game Object has this component. @@ -30820,7 +31888,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -31152,830 +32220,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. Ensure this value is only ever set to a number data-type. - * - * 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. Ensure this value is only ever a number data-type. - */ - 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, or any kind of Shape Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): 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. - */ - postPipelines: 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 set 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; - - /** - * A property indicating that a Game Object has this component. - */ - readonly hasTransformComponent: boolean; - - /** - * 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 @@ -32093,6 +32337,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -32107,7 +32352,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -32116,6 +32361,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -32129,9 +32375,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -32278,7 +32524,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -32801,6 +33047,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -32815,7 +33062,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -32824,6 +33071,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -32837,9 +33085,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -32986,7 +33234,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -33519,6 +33767,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -33533,7 +33782,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -33542,6 +33791,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -33555,9 +33805,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -33704,7 +33954,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -34307,6 +34557,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -34321,7 +34572,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -34330,6 +34581,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -34343,9 +34595,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -34492,7 +34744,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -35062,6 +35314,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -35076,7 +35329,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -35085,6 +35338,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -35098,9 +35352,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -35247,7 +35501,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -35831,6 +36085,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -35845,7 +36100,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -35854,6 +36109,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -35867,9 +36123,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -36016,7 +36272,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -36556,6 +36812,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -36570,7 +36827,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -36579,6 +36836,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -36592,9 +36850,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -36741,7 +36999,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -37281,6 +37539,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -37295,7 +37554,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -37304,6 +37563,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -37317,9 +37577,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -37466,7 +37726,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -37980,6 +38240,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -37994,7 +38255,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -38003,6 +38264,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -38016,9 +38278,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -38165,7 +38427,833 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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, or any kind of Shape Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): 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. + */ + postPipelines: 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 set 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; + + /** + * A property indicating that a Game Object has this component. + */ + readonly hasTransformComponent: boolean; + + /** + * 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 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: + * + * * NORMAL + * * 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 | 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: + * + * * NORMAL + * * 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, a CONST or a number. + */ + setBlendMode(value: string | Phaser.BlendModes | number): this; + + /** + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. + * + * 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. Ensure this value is only ever a number data-type. + */ + 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 texture-based 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; @@ -38712,6 +39800,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -38726,7 +39815,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -38735,6 +39824,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -38748,9 +39838,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -38897,7 +39987,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -39418,6 +40508,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -39432,7 +40523,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -39441,6 +40532,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -39454,9 +40546,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -39603,7 +40695,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -40376,6 +41468,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -40390,7 +41483,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -40399,6 +41492,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -40412,9 +41506,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -40668,7 +41762,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -41057,17 +42151,19 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * The Frame has to belong to the current Texture being used. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * It can be either a string or an index. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture. + * @param frame The name or index of the frame within the Texture, or a Frame instance. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -41853,6 +42949,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -41867,7 +42964,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -41876,6 +42973,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -41889,9 +42987,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The displayed width of this Game Object. @@ -42233,7 +43331,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -43391,6 +44489,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -43405,7 +44504,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -43414,6 +44513,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -43427,9 +44527,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The native (un-scaled) width of this Game Object. @@ -43779,7 +44879,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -44335,6 +45435,55 @@ 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. * @@ -44913,6 +46062,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -44927,7 +46077,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -44936,6 +46086,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -44949,9 +46100,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -45196,7 +46347,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -45585,17 +46736,19 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * The Frame has to belong to the current Texture being used. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * It can be either a string or an index. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture. + * @param frame The name or index of the frame within the Texture, or a Frame instance. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -49165,1343 +50318,6 @@ 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 | null; - - /** - * A reference to the Mouse Manager class, if enabled via the `input.mouse` Game Config property. - */ - mouse: Phaser.Input.Mouse.MouseManager | null; - - /** - * 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 | null; - - /** - * 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 | null; - - /** - * 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): this; - - /** - * 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 | null; - - /** - * 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 | null; - - } - - 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 | WheelEvent; - - /** - * 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. */ @@ -50547,6 +50363,27 @@ 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. @@ -51355,6 +51192,380 @@ declare namespace Phaser { } + namespace Configs { + /** + * Tatar SNES USB Controller Gamepad Configuration. + * USB Gamepad (STANDARD GAMEPAD Vendor: 0079 Product: 0011) + */ + namespace SNES_USB { + /** + * D-Pad up + */ + const UP: number; + + /** + * D-Pad down + */ + const DOWN: number; + + /** + * D-Pad left + */ + const LEFT: number; + + /** + * D-Pad right + */ + const RIGHT: number; + + /** + * Select button + */ + const SELECT: number; + + /** + * Start button + */ + const START: number; + + /** + * B Button (Bottom) + */ + const B: number; + + /** + * A Button (Right) + */ + const A: number; + + /** + * Y Button (Left) + */ + const Y: number; + + /** + * X Button (Top) + */ + const X: number; + + /** + * Left bumper + */ + const LEFT_SHOULDER: number; + + /** + * Right bumper + */ + const RIGHT_SHOULDER: number; + + } + + /** + * PlayStation DualShock 4 Gamepad Configuration. + * Sony PlayStation DualShock 4 (v2) wireless controller + */ + namespace DUALSHOCK_4 { + /** + * D-Pad up + */ + const UP: number; + + /** + * D-Pad down + */ + const DOWN: number; + + /** + * D-Pad left + */ + const LEFT: number; + + /** + * D-Pad up + */ + const RIGHT: number; + + /** + * Share button + */ + const SHARE: number; + + /** + * Options button + */ + const OPTIONS: number; + + /** + * PlayStation logo button + */ + const PS: number; + + /** + * Touchpad click + */ + const TOUCHBAR: number; + + /** + * Cross button (Bottom) + */ + const X: number; + + /** + * Circle button (Right) + */ + const CIRCLE: number; + + /** + * Square button (Left) + */ + const SQUARE: number; + + /** + * Triangle button (Top) + */ + const TRIANGLE: number; + + /** + * Left bumper (L1) + */ + const L1: number; + + /** + * Right bumper (R1) + */ + const R1: number; + + /** + * Left trigger (L2) + */ + const L2: number; + + /** + * Right trigger (R2) + */ + const R2: number; + + /** + * Left stick click (L3) + */ + const L3: number; + + /** + * Right stick click (R3) + */ + const R3: number; + + /** + * Left stick horizontal + */ + const LEFT_STICK_H: number; + + /** + * Left stick vertical + */ + const LEFT_STICK_V: number; + + /** + * Right stick horizontal + */ + const RIGHT_STICK_H: number; + + /** + * Right stick vertical + */ + const RIGHT_STICK_V: number; + + } + + /** + * XBox 360 Gamepad Configuration. + */ + namespace XBOX_360 { + /** + * D-Pad up + */ + const UP: number; + + /** + * D-Pad down + */ + const DOWN: number; + + /** + * D-Pad left + */ + const LEFT: number; + + /** + * D-Pad right + */ + const RIGHT: number; + + /** + * XBox menu button + */ + const MENU: number; + + /** + * A button (Bottom) + */ + const A: number; + + /** + * B button (Right) + */ + const B: number; + + /** + * X button (Left) + */ + const X: number; + + /** + * Y button (Top) + */ + const Y: number; + + /** + * Left Bumper + */ + const LB: number; + + /** + * Right Bumper + */ + const RB: number; + + /** + * Left Trigger + */ + const LT: number; + + /** + * Right Trigger + */ + const RT: number; + + /** + * Back / Change View button + */ + const BACK: number; + + /** + * Start button + */ + const START: number; + + /** + * Left Stick press + */ + const LS: number; + + /** + * Right stick press + */ + const RS: number; + + /** + * Left Stick horizontal + */ + const LEFT_STICK_H: number; + + /** + * Left Stick vertical + */ + const LEFT_STICK_V: number; + + /** + * Right Stick horizontal + */ + const RIGHT_STICK_H: number; + + /** + * Right Stick vertical + */ + const RIGHT_STICK_V: number; + + } + + } + + 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + } + /** * A single Gamepad. * @@ -51726,383 +51937,1102 @@ declare namespace Phaser { } - namespace Configs { + } + + /** + * 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 | null; + + /** + * A reference to the Mouse Manager class, if enabled via the `input.mouse` Game Config property. + */ + mouse: Phaser.Input.Mouse.MouseManager | null; + + /** + * 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 | null; + + /** + * 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 | null; + + /** + * 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 | null; + + /** + * 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): this; + + /** + * 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 | null; + + } + + 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 { /** - * Tatar SNES USB Controller Gamepad Configuration. - * USB Gamepad (STANDARD GAMEPAD Vendor: 0079 Product: 0011) + * + * @param keyboardPlugin A reference to the Keyboard Plugin. + * @param keys The keys that comprise this combo. + * @param config A Key Combo configuration object. */ - namespace SNES_USB { - /** - * D-Pad up - */ - const UP: number; - - /** - * D-Pad down - */ - const DOWN: number; - - /** - * D-Pad left - */ - const LEFT: number; - - /** - * D-Pad right - */ - const RIGHT: number; - - /** - * Select button - */ - const SELECT: number; - - /** - * Start button - */ - const START: number; - - /** - * B Button (Bottom) - */ - const B: number; - - /** - * A Button (Right) - */ - const A: number; - - /** - * Y Button (Left) - */ - const Y: number; - - /** - * X Button (Top) - */ - const X: number; - - /** - * Left bumper - */ - const LEFT_SHOULDER: number; - - /** - * Right bumper - */ - const RIGHT_SHOULDER: number; - - } + constructor(keyboardPlugin: Phaser.Input.Keyboard.KeyboardPlugin, keys: string | number[] | object[], config?: Phaser.Types.Input.Keyboard.KeyComboConfig); /** - * PlayStation DualShock 4 Gamepad Configuration. - * Sony PlayStation DualShock 4 (v2) wireless controller + * A reference to the Keyboard Manager */ - namespace DUALSHOCK_4 { - /** - * D-Pad up - */ - const UP: number; - - /** - * D-Pad down - */ - const DOWN: number; - - /** - * D-Pad left - */ - const LEFT: number; - - /** - * D-Pad up - */ - const RIGHT: number; - - /** - * Share button - */ - const SHARE: number; - - /** - * Options button - */ - const OPTIONS: number; - - /** - * PlayStation logo button - */ - const PS: number; - - /** - * Touchpad click - */ - const TOUCHBAR: number; - - /** - * Cross button (Bottom) - */ - const X: number; - - /** - * Circle button (Right) - */ - const CIRCLE: number; - - /** - * Square button (Left) - */ - const SQUARE: number; - - /** - * Triangle button (Top) - */ - const TRIANGLE: number; - - /** - * Left bumper (L1) - */ - const L1: number; - - /** - * Right bumper (R1) - */ - const R1: number; - - /** - * Left trigger (L2) - */ - const L2: number; - - /** - * Right trigger (R2) - */ - const R2: number; - - /** - * Left stick click (L3) - */ - const L3: number; - - /** - * Right stick click (R3) - */ - const R3: number; - - /** - * Left stick horizontal - */ - const LEFT_STICK_H: number; - - /** - * Left stick vertical - */ - const LEFT_STICK_V: number; - - /** - * Right stick horizontal - */ - const RIGHT_STICK_H: number; - - /** - * Right stick vertical - */ - const RIGHT_STICK_V: number; - - } + manager: Phaser.Input.Keyboard.KeyboardPlugin; /** - * XBox 360 Gamepad Configuration. + * A flag that controls if this Key Combo is actively processing keys or not. */ - namespace XBOX_360 { - /** - * D-Pad up - */ - const UP: number; + enabled: boolean; - /** - * D-Pad down - */ - const DOWN: number; + /** + * An array of the keycodes that comprise this combo. + */ + keyCodes: any[]; - /** - * D-Pad left - */ - const LEFT: number; + /** + * The current keyCode the combo is waiting for. + */ + current: number; - /** - * D-Pad right - */ - const RIGHT: number; + /** + * The current index of the key being waited for in the 'keys' string. + */ + index: number; - /** - * XBox menu button - */ - const MENU: number; + /** + * The length of this combo (in keycodes) + */ + size: number; - /** - * A button (Bottom) - */ - const A: number; + /** + * The time the previous key in the combo was matched. + */ + timeLastMatched: number; - /** - * B button (Right) - */ - const B: number; + /** + * Has this Key Combo been matched yet? + */ + matched: boolean; - /** - * X button (Left) - */ - const X: number; + /** + * The time the entire combo was matched. + */ + timeMatched: number; - /** - * Y button (Top) - */ - const Y: number; + /** + * If they press the wrong key do we reset the combo? + */ + resetOnWrongKey: boolean; - /** - * Left Bumper - */ - const LB: number; + /** + * The max delay in ms between each key press. Above this the combo is reset. 0 means disabled. + */ + maxKeyDelay: number; - /** - * Right Bumper - */ - const RB: number; + /** + * If previously matched and they press the first key of the combo again, will it reset? + */ + resetOnMatch: boolean; - /** - * Left Trigger - */ - const LT: number; + /** + * If the combo matches, will it delete itself? + */ + deleteOnMatch: boolean; - /** - * Right Trigger - */ - const RT: number; + /** + * How far complete is this combo? A value between 0 and 1. + */ + readonly progress: number; - /** - * Back / Change View button - */ - const BACK: number; - - /** - * Start button - */ - const START: number; - - /** - * Left Stick press - */ - const LS: number; - - /** - * Right stick press - */ - const RS: number; - - /** - * Left Stick horizontal - */ - const LEFT_STICK_H: number; - - /** - * Left Stick vertical - */ - const LEFT_STICK_V: number; - - /** - * Right Stick horizontal - */ - const RIGHT_STICK_H: number; - - /** - * Right Stick vertical - */ - const RIGHT_STICK_V: number; - - } + /** + * Destroys this Key Combo and all of its references. + */ + destroy(): void; } namespace Events { /** - * The Gamepad Button Down Event. + * The Global Key Down Event. * - * This event is dispatched by the Gamepad Plugin when a button has been pressed on any active Gamepad. + * 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.gamepad.on('down', listener)`. + * Listen to this event from within a Scene using: `this.input.keyboard.on('keydown', 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. + * 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 BUTTON_DOWN: any; + const ANY_KEY_DOWN: string; /** - * The Gamepad Button Up Event. + * The Global Key Up Event. * - * This event is dispatched by the Gamepad Plugin when a button has been released on any active Gamepad. + * 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.gamepad.on('up', listener)`. + * Listen to this event from within a Scene using: `this.input.keyboard.on('keyup', 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. + * 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 BUTTON_UP: any; + const ANY_KEY_UP: string; /** - * The Gamepad Connected Event. + * The Key Combo Match Event. * - * This event is dispatched by the Gamepad Plugin when a Gamepad has been connected. + * This event is dispatched by the Keyboard Plugin when a [Key Combo]{@link Phaser.Input.Keyboard.KeyCombo} is matched. * - * Listen to this event from within a Scene using: `this.input.gamepad.once('connected', listener)`. + * Listen for this event from the Key Plugin after a combo has been created: * - * 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. + * ```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 CONNECTED: any; + const COMBO_MATCH: string; /** - * The Gamepad Disconnected Event. + * The Key Down Event. * - * This event is dispatched by the Gamepad Plugin when a Gamepad has been disconnected. + * This event is dispatched by a [Key]{@link Phaser.Input.Keyboard.Key} object when it is pressed. * - * Listen to this event from within a Scene using: `this.input.gamepad.once('disconnected', listener)`. + * 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 DISCONNECTED: any; + const DOWN: string; /** - * The Gamepad Button Down Event. + * The Key Down Event. * - * This event is dispatched by a Gamepad instance when a button has been pressed on it. + * This event is dispatched by the Keyboard Plugin when any key on the keyboard is pressed down. * - * 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)`. + * 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)`. * - * Note that you will not receive any Gamepad button events until the browser considers the Gamepad as being 'connected'. + * 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. * - * 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. + * 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 GAMEPAD_BUTTON_DOWN: any; + const KEY_DOWN: string; /** - * The Gamepad Button Up Event. + * The Key Up Event. * - * This event is dispatched by a Gamepad instance when a button has been released on it. + * This event is dispatched by the Keyboard Plugin when any key on the keyboard is released. * - * 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)`. + * 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)`. * - * Note that you will not receive any Gamepad button events until the browser considers the Gamepad as being 'connected'. + * 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. * - * 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. + * 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 GAMEPAD_BUTTON_UP: any; + const KEY_UP: string; + + /** + * 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: string; } - } - - namespace Keyboard { /** * The Keyboard Manager is a helper class that belongs to the global Input Manager. * @@ -52579,245 +53509,6 @@ 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. @@ -53684,6 +54375,468 @@ 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 | WheelEvent; + + /** + * 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. @@ -53808,6 +54961,223 @@ 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; + + /** + * File is pending being destroyed. + */ + var FILE_PENDING_DESTROY: 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: string; + + /** + * 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: string; + + /** + * 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)`. + * + * Make sure you remove this listener when you have finished, or it will continue to fire if the Scene reloads. + * + * 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: string; + + /** + * 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 + * }); + * ``` + * + * Make sure you remove your listeners when you have finished, or they will continue to fire if the Scene reloads. + * + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + } + /** * 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. @@ -54015,6 +55385,961 @@ 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?: Phaser.Types.Loader.FileTypes.AudioFileURLConfig, 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 Compressed Texture File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#texture method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#texture. + */ + class CompressedTextureFile 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. + * @param entry The compressed texture file entry to load. + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string, entry: Phaser.Types.Loader.FileTypes.CompressedTextureFileEntry, xhrSettings?: 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; + + /** + * Adds all of the multi-file entties to their target caches upon successful loading and processing. + */ + addMultiToCache(): 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 type The script type. Should be either 'script' for classic JavaScript, or 'module' if the file contains an exported module. Default 'script'. + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.ScriptFileConfig, url?: string, type?: 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?: Phaser.Types.Loader.FileTypes.VideoFileURLConfig, 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. @@ -54080,348 +56405,6 @@ 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; - - /** - * Optional load type for image files. `XHR` is the default. Set to `HTMLImageElement` to load images using the Image tag instead. - */ - imageLoadType: string; - - /** - * An array of all schemes that the Loader considers as being 'local'. - * - * This is populated by the `Phaser.Core.Config#loaderLocalScheme` game configuration setting and defaults to - * `[ 'file://', 'capacitor://' ]`. Additional local schemes can be added to this array as needed. - */ - localSchemes: 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. * @@ -55146,57 +57129,6 @@ declare namespace Phaser { */ bitmapFont(key: string | Phaser.Types.Loader.FileTypes.BitmapFontFileConfig | Phaser.Types.Loader.FileTypes.BitmapFontFileConfig[], textureURL?: string | string[], fontDataURL?: string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, fontDataXhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; - /** - * Adds a CSS file, or array of CSS files, to the current load queue. - * - * 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.css('headers', 'styles/headers.css'); - * } - * ``` - * - * 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 and not already in-use by another file in the Loader. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.css({ - * key: 'headers', - * url: 'styles/headers.css' - * }); - * ``` - * - * See the documentation for `Phaser.Types.Loader.FileTypes.CSSFileConfig` for more details. - * - * Once the file has finished loading it will automatically be converted into a style DOM element - * via `document.createElement('style')`. It will have its `defer` property set to false and then the - * resulting element will be appended to `document.head`. The CSS styles are then applied to the current document. - * - * 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.css". It will always add `.css` 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. - * - * Note: The ability to load this type of file will only be available if the CSS 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 `.css`, i.e. if `key` was "alien" then the URL will be "alien.css". - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - css(key: string | Phaser.Types.Loader.FileTypes.CSSFileConfig | Phaser.Types.Loader.FileTypes.CSSFileConfig[], url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; - /** * Adds a Compressed Texture file to the current load queue. This feature is WebGL only. * @@ -55331,6 +57263,57 @@ declare namespace Phaser { */ texture(key: string | Phaser.Types.Loader.FileTypes.CompressedTextureFileConfig | Phaser.Types.Loader.FileTypes.CompressedTextureFileConfig[], url?: Phaser.Types.Loader.FileTypes.CompressedTextureFileConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; + /** + * Adds a CSS file, or array of CSS files, to the current load queue. + * + * 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.css('headers', 'styles/headers.css'); + * } + * ``` + * + * 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 and not already in-use by another file in the Loader. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.css({ + * key: 'headers', + * url: 'styles/headers.css' + * }); + * ``` + * + * See the documentation for `Phaser.Types.Loader.FileTypes.CSSFileConfig` for more details. + * + * Once the file has finished loading it will automatically be converted into a style DOM element + * via `document.createElement('style')`. It will have its `defer` property set to false and then the + * resulting element will be appended to `document.head`. The CSS styles are then applied to the current document. + * + * 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.css". It will always add `.css` 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. + * + * Note: The ability to load this type of file will only be available if the CSS 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 `.css`, i.e. if `key` was "alien" then the URL will be "alien.css". + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + css(key: string | Phaser.Types.Loader.FileTypes.CSSFileConfig | Phaser.Types.Loader.FileTypes.CSSFileConfig[], url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; + /** * Adds a GLSL file, or array of GLSL files, to the current load queue. * In Phaser 3 GLSL files are just plain Text files at the current moment in time. @@ -56100,118 +58083,6 @@ 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. * @@ -56522,6 +58393,118 @@ 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. * @@ -56991,6 +58974,348 @@ 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; + + /** + * Optional load type for image files. `XHR` is the default. Set to `HTMLImageElement` to load images using the Image tag instead. + */ + imageLoadType: string; + + /** + * An array of all schemes that the Loader considers as being 'local'. + * + * This is populated by the `Phaser.Core.Config#loaderLocalScheme` game configuration setting and defaults to + * `[ 'file://', 'capacitor://' ]`. Additional local schemes can be added to this array as needed. + */ + localSchemes: 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; + } /** @@ -57140,1181 +59465,129 @@ 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; - - /** - * 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; - - /** - * File is pending being destroyed. - */ - var FILE_PENDING_DESTROY: 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)`. - * - * Make sure you remove this listener when you have finished, or it will continue to fire if the Scene reloads. - * - * 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 - * }); - * ``` - * - * Make sure you remove your listeners when you have finished, or they will continue to fire if the Scene reloads. - * - * 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; - - } - - 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?: Phaser.Types.Loader.FileTypes.AudioFileURLConfig, 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 Compressed Texture File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#texture method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#texture. - */ - class CompressedTextureFile 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. - * @param entry The compressed texture file entry to load. - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string, entry: Phaser.Types.Loader.FileTypes.CompressedTextureFileEntry, xhrSettings?: 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; - - /** - * Adds all of the multi-file entties to their target caches upon successful loading and processing. - */ - addMultiToCache(): 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 type The script type. Should be either 'script' for classic JavaScript, or 'module' if the file contains an exported module. Default 'script'. - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.ScriptFileConfig, url?: string, type?: 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?: Phaser.Types.Loader.FileTypes.VideoFileURLConfig, 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 { + 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; + + } + /** * Calculate the mean average of the given values. * @param values The values to average. @@ -58363,6 +59636,49 @@ 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. @@ -58376,6 +59692,313 @@ 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 { /** * @@ -58418,6 +60041,53 @@ 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. @@ -58425,6 +60095,67 @@ 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. @@ -58923,6 +60654,29 @@ 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. */ @@ -59128,6 +60882,149 @@ 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. * @@ -59244,18 +61141,6 @@ 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`. * @@ -59270,6 +61155,56 @@ 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. * @@ -60109,788 +62044,6 @@ 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; - - } - } /** @@ -61585,7 +62738,7 @@ declare namespace Phaser { /** * A scene or scenes to add to the game. If several are given, the first is started; the remainder are started only if they have `{ active: true }`. See the `sceneConfig` argument in `Phaser.Scenes.SceneManager#add`. */ - scene?: SceneType | SceneType[]; + scene?: Phaser.Types.Scenes.SceneType | Phaser.Types.Scenes.SceneType[]; /** * Seed for the random number generator. */ @@ -64563,6 +65716,8 @@ 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? @@ -64582,8 +65737,6 @@ declare namespace Phaser { deleteOnMatch?: boolean; }; - type KeyboardKeydownCallback = (event: KeyboardEvent)=>void; - } /** @@ -64961,25 +66114,6 @@ declare namespace Phaser { fontDataXhrSettings?: Phaser.Types.Loader.XHRSettingsObject; }; - type CSSFileConfig = { - /** - * The key of the file. Must be unique within the Loader. - */ - 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; - }; - type CompressedTextureFileEntry = { /** * The texture compression base format that the browser must support in order to load this file. Can be any of: 'ETC', 'ETC1', 'ATC', 'ASTC', 'BPTC', 'RGTC', 'PVRTC', 'S3TC', 'S3TCSRGB' or the fallback format of 'IMG'. @@ -65054,6 +66188,25 @@ declare namespace Phaser { IMG?: Phaser.Types.Loader.FileTypes.CompressedTextureFileEntry | string; }; + type CSSFileConfig = { + /** + * The key of the file. Must be unique within the Loader. + */ + 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; + }; + type GLSLFileConfig = { /** * The key of the file. Must be unique within both the Loader and the Text Cache. @@ -65358,44 +66511,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 SceneFileConfig = { /** * The key of the file. Must be unique within both the Loader and the Text Cache. @@ -65492,6 +66607,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 TextFileConfig = { /** * The key of the file. Must be unique within both the Loader and the Text Cache. @@ -67572,6 +68725,8 @@ declare namespace Phaser { data?: any; }; + type SceneType = Phaser.Scene | Phaser.Types.Scenes.SettingsConfig | Phaser.Types.Scenes.CreateSceneFromObjectConfig | Function; + type SceneUpdateCallback = (this: Phaser.Scene, time: number, delta: number)=>void; type SettingsConfig = { @@ -67933,6 +69088,56 @@ declare namespace Phaser { spacing?: number; }; + /** + * An object containing the position and color data for a single pixel in a CanvasTexture. + */ + type StampConfig = { + /** + * The alpha value used by the stamp. + */ + alpha?: number; + /** + * The tint color value used by the stamp. WebGL only. + */ + tint?: number; + /** + * The angle of the stamp in degrees. Rotation takes place around its origin. + */ + angle?: number; + /** + * The rotation of the stamp in radians. Rotation takes place around its origin. + */ + rotation?: number; + /** + * Sets both the horizontal and vertical scale of the stamp with a single value. + */ + scale?: number; + /** + * Set the horizontal scale of the stamp. Overrides the scale property, if provided. + */ + scaleX?: number; + /** + * Set the vertical scale of the stamp. Overrides the scale property, if provided. + */ + scaleY?: number; + /** + * The horizontal origin of the stamp. 0 is the left, 0.5 is the center and 1 is the right. + */ + originX?: number; + /** + * The vertical origin of the stamp. 0 is the top, 0.5 is the center and 1 is the bottom. + */ + originY?: number; + /** + * The blend mode used when drawing the stamp. Defaults to 0 (normal). + */ + blendMode?: string | Phaser.BlendModes | number; + /** + * Erase this stamp from the texture? + */ + erase?: boolean; + }; + } namespace Tilemaps { @@ -68836,8 +70041,6 @@ declare namespace Phaser { interpolation?: string | Function; }; - type TweenCallbackTypes = 'onActive' | 'onComplete' | 'onLoop' | 'onPause' | 'onRepeat' | 'onResume' | 'onStart' | 'onStop' | 'onUpdate' | 'onYoyo'; - type TweenCallbacks = { /** * A function to call when the tween becomes active within the Tween Manager. @@ -68881,6 +70084,8 @@ declare namespace Phaser { onYoyo?: Phaser.Types.Tweens.TweenOnYoyoCallback; }; + type TweenCallbackTypes = 'onActive' | 'onComplete' | 'onLoop' | 'onPause' | 'onRepeat' | 'onResume' | 'onStart' | 'onStop' | 'onUpdate' | 'onYoyo'; + type TweenChainBuilderConfig = { /** * The object, or an array of objects, to run the tween on. @@ -69370,6 +70575,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -69384,7 +70590,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -69393,6 +70599,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -69406,9 +70613,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -69662,7 +70869,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -70051,17 +71258,19 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * The Frame has to belong to the current Texture being used. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * It can be either a string or an index. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture. + * @param frame The name or index of the frame within the Texture, or a Frame instance. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -71082,6 +72291,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -71096,7 +72306,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -71105,6 +72315,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -71118,9 +72329,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -71374,7 +72585,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -71763,17 +72974,19 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * The Frame has to belong to the current Texture being used. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * It can be either a string or an index. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture. + * @param frame The name or index of the frame within the Texture, or a Frame instance. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -73385,6 +74598,562 @@ 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. + * @param onWorldBounds If given this replaces the Body's `onWorldBounds` value. + */ + setCollideWorldBounds(value?: boolean, bounceX?: number, bounceY?: number, onWorldBounds?: boolean): 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + } + /** * 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. @@ -74099,6 +75868,73 @@ 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. * @@ -74687,629 +76523,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. - * @param onWorldBounds If given this replaces the Body's `onWorldBounds` value. - */ - setCollideWorldBounds(value?: boolean, bounceX?: number, bounceY?: number, onWorldBounds?: boolean): 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 { @@ -75448,9 +76661,743 @@ 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: string; + + 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: string; + + 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: string; + + 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: string; + + 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: string; + + 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: string; + + 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: string; + + 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: string; + + 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + 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: string; + + 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: string; + + } + /** * 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. @@ -76025,6 +77972,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -76039,7 +77987,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -76048,6 +77996,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -76061,9 +78010,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -76317,7 +78266,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -76706,17 +78655,19 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * The Frame has to belong to the current Texture being used. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * It can be either a string or an index. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture. + * @param frame The name or index of the frame within the Texture, or a Frame instance. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -78003,6 +79954,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -78017,7 +79969,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -78026,6 +79978,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -78039,9 +79992,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -78295,7 +80248,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -78684,17 +80637,19 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * The Frame has to belong to the current Texture being used. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * It can be either a string or an index. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture. + * @param frame The name or index of the frame within the Texture, or a Frame instance. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -80320,740 +82275,6 @@ 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; - - } - } } @@ -81756,24 +82977,6 @@ 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 { /** @@ -82053,7 +83256,7 @@ declare namespace Phaser { * This event is dispatched by the Renderer when all rendering, for all cameras in all Scenes, * has completed, but before any pending snap shots have been taken. */ - const POST_RENDER: any; + const POST_RENDER: string; /** * The Pre-Render Event. @@ -82062,7 +83265,7 @@ declare namespace Phaser { * process, after the context has been cleared, the scissors enabled (WebGL only) and everything has been * reset ready for the render. */ - const PRE_RENDER: any; + const PRE_RENDER: string; /** * The Render Event. @@ -82071,7 +83274,7 @@ declare namespace Phaser { * * It is dispatched before any of the children in the Scene have been rendered. */ - const RENDER: any; + const RENDER: string; /** * The Renderer Resize Event. @@ -82079,7 +83282,7 @@ declare namespace Phaser { * This event is dispatched by the Phaser Renderer when it is resized, usually as a result * of the Scale Manager resizing. */ - const RESIZE: any; + const RESIZE: string; } @@ -82107,6 +83310,41 @@ 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. @@ -82613,6 +83851,1501 @@ 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 The BitmapMask instance that called beginMask. + * @param maskedObject GameObject masked by the mask GameObject. + * @param camera The camera rendering the current mask. + */ + beginMask(mask: Phaser.Display.Masks.BitmapMask, 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 The BitmapMask instance that called endMask. + * @param camera The Camera to render to. + * @param renderTarget Optional WebGL RenderTarget. + */ + endMask(mask: Phaser.Display.Masks.BitmapMask, camera: Phaser.Cameras.Scene2D.Camera, renderTarget?: Phaser.Renderer.WebGL.RenderTarget): 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 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; + + /** + * A persistent calculation vector used when processing the lights. + */ + tempVec2: Phaser.Math.Vec2; + + /** + * 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 should use the string + * declaration `%count%` in your fragment shader source, which is used to set the number of + * `sampler2Ds` available. Also add `%getSampler%` so Phaser can inject the getSampler glsl function. + * This function can be used to get the pixel vec4 from the texture: + * + * `vec4 texture = getSampler(int(outTexId), outTexCoord);` + * + * This pipeline will automatically inject the getSampler function for you, should the value 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); + + /** + * A temporary Transform Matrix, re-used internally during batching by the + * Shape Game Objects. + */ + calcMatrix: Phaser.GameObjects.Components.TransformMatrix; + + /** + * 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; + + /** + * 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; + + } + + /** + * 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 SpriteFX Pipeline is a special kind of pipeline designed specifically for applying + * special effects to Sprites. Where-as the Post FX Pipeline applies an effect _after_ the + * object has been rendered, the Sprite FX Pipeline allows you to control the rendering of + * the object itself - passing it off to its own texture where multi-buffer compositing + * can take place. + * + * You can only use the SpriteFX Pipeline on the following types of Game Objects, or those + * that extend from them: + * + * Sprite + * Image + * Text + * TileSprite + * RenderTexture + * + * // TODO - Explain about the fbos and functions + */ + class SpriteFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + + /** + * A reference to the Draw Sprite Shader belonging to this Pipeline. + * + * This shader is used when the sprite is drawn to this fbo (or to the game if drawToFrame is false) + * + * This property is set during the `boot` method. + */ + drawSpriteShader: Phaser.Renderer.WebGL.WebGLShader; + + /** + * A reference to the Copy Shader belonging to this Pipeline. + * + * This shader is used when you call the `copySprite` method. + * + * This property is set during the `boot` method. + */ + copyShader: Phaser.Renderer.WebGL.WebGLShader; + + /** + * A reference to the Game Draw Shader belonging to this Pipeline. + * + * This shader draws the fbo to the game. + * + * This property is set during the `boot` method. + */ + gameShader: Phaser.Renderer.WebGL.WebGLShader; + + /** + * Raw byte buffer of vertices used specifically during the copySprite method. + */ + readonly quadVertexData: ArrayBuffer; + + /** + * The WebGLBuffer that holds the quadVertexData. + */ + readonly quadVertexBuffer: WebGLBuffer; + + /** + * Float32 view of the quad array buffer. + */ + quadVertexViewF32: Float32Array; + + /** + * The full-screen Render Target that the sprite is first drawn to. + */ + fsTarget: Phaser.Renderer.WebGL.RenderTarget; + + /** + * Handles the resizing of the quad vertex data. + * @param width The new width of the quad. + * @param height The new height of the quad. + */ + onResize(width: number, height: number): void; + + /** + * Takes a Sprite Game Object, or any object that extends it, and renders it via this pipeline. + * + * this method is a proxy for the MultiPipeline method of the same name. The actual rendering + * is redirected through to the `batchQuad` method in this pipeline. + * @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 the vertices data into the batch and flushes if full. + * + * Assumes 6 vertices in the following arrangement: + * + * ``` + * 0----3 + * |\ B| + * | \ | + * | \ | + * | A \| + * | \ + * 1----2 + * ``` + * + * Where x0 / y0 = 0, x1 / y1 = 1, x2 / y2 = 2 and x3 / y3 = 3 + * @param gameObject The Game Object, if any, drawing this quad. + * @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 u0 UV u0 value. + * @param v0 UV v0 value. + * @param u1 UV u1 value. + * @param v1 UV v1 value. + * @param tintTL The top-left tint color value. + * @param tintTR The top-right tint color value. + * @param tintBL The bottom-left tint color value. + * @param tintBR The bottom-right tint color value. + * @param tintEffect The tint effect for the shader to use. + * @param texture WebGLTexture that will be assigned to the current batch if a flush occurs. + */ + batchQuad(gameObject: Phaser.GameObjects.GameObject | null, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, u0: number, v0: number, u1: number, v1: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number | boolean, texture?: WebGLTexture): boolean; + + /** + * This callback is invoked when a sprite is drawn by this pipeline. + * + * It will fire after the shader has been set, but before the sprite has been drawn, + * so use it to set any additional uniforms you may need. + * + * Note: Manipulating the Sprite during this callback will _not_ change how it is drawn to the Render Target. + * @param gameObject The Sprite being drawn. + * @param target The Render Target the Sprite will be drawn to. + */ + onDrawSprite(gameObject: Phaser.GameObjects.Sprite, target: Phaser.Renderer.WebGL.RenderTarget): void; + + /** + * This callback is invoked when you call the `copySprite` method. + * + * It will fire after the shader has been set, but before the source target has been copied, + * so use it to set any additional uniforms you may need. + * + * Note: Manipulating the Sprite during this callback will _not_ change the Render Targets. + * @param source The source Render Target being copied from. + * @param target The target Render Target that will be copied to. + * @param gameObject The Sprite being copied. + */ + onCopySprite(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, gameObject: Phaser.GameObjects.Sprite): void; + + /** + * Copy the `source` Render Target to the `target` Render Target. + * + * No target 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. + * + * Calling this method will invoke the `onCopySprite` handler and will also call + * the `onFXCopy` callback on the Sprite. Both of these happen prior to the copy, allowing you + * to use them to set shader uniforms and other values. + * @param source The source Render Target being copied from. + * @param target The target Render Target that will be copied to. + * @param gameObject The Sprite being copied. + * @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. + * @param shader The shader to use to copy the target. Defaults to the `copyShader`. + */ + copySprite(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, gameObject: Phaser.GameObjects.Sprite, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean, shader?: Phaser.Renderer.WebGL.WebGLShader): 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; + + /** + * This method will copy the given Render Target to the game canvas using the `copyShader`. + * + * This applies the results of the copy shader during the draw. + * + * If you wish to copy the target without any effects see the `copyToGame` method instead. + * + * This method should be the final thing called in your pipeline. + * @param source The Render Target to draw to the game. + */ + drawToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; + + /** + * This method will copy the given Render Target to the game canvas using the `gameShader`. + * + * Unless you've changed it, the `gameShader` copies the target without modifying it, just + * ensuring it is placed in the correct location on the canvas. + * + * If you wish to draw the target with and apply the fragment shader at the same time, + * see the `drawToGame` method instead. + * + * This method should be the final thing called in your pipeline. + * @param source The Render Target to copy to the game. + */ + copyToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; + + /** + * This method is called by `drawToGame` and `copyToGame`. It takes the source Render Target + * and copies it back to the game canvas, or the next frame buffer in the stack, and should + * be considered the very last thing this pipeline does. + * + * You don't normally need to call this method, or override it, however it is left public + * should you wish to do so. + * + * Note that it does _not_ set a shader. You should do this yourself if invoking this. + * @param source The Render Target to draw to the game. + */ + bindAndDraw(source: Phaser.Renderer.WebGL.RenderTarget): void; + + /** + * This method is called every time the `batchSprite` method is called and is passed a + * reference to the current render target. + * + * If you override this method, then it should make sure it calls either the + * `drawToGame` or `copyToGame` methods as the final thing it does. However, you can do as + * much additional processing as you like prior to this. + * @param target The Render Target to draw to the game. + * @param swapTarget The Swap Render Target, useful for double-buffer effects. + * @param altSwapTarget The Swap Render Target, useful for double-buffer effects. + */ + onDraw(target: Phaser.Renderer.WebGL.RenderTarget, swapTarget?: Phaser.Renderer.WebGL.RenderTarget, altSwapTarget?: Phaser.Renderer.WebGL.RenderTarget): void; + + /** + * Set the UV values for the 6 vertices that make up the quad used by the copy shader. + * + * 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 copy shaders + * 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; + + /** + * Resets the quad vertice UV values to their default settings. + * + * The quad is used by the copy shader in this pipeline. + */ + resetUVs(): void; + + /** + * Destroys all shader instances, removes all object references and nulls all external references. + */ + destroy(): this; + + } + + /** + * 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. + * @param flipY Flip the UV on the Y axis before drawing? Default false. + */ + blitFrame(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean, flipY?: 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. * @@ -82783,6 +85516,8 @@ declare namespace Phaser { /** * Check to see how many texture units the GPU supports in a fragment shader * and if the value specific in the game config is allowed. + * + * This value is hard-clamped to 16 for performance reasons on Android devices. * @param gl The WebGLContext used to create the shaders. * @param maxTextures The Game Config maxTextures value. */ @@ -84099,6 +86834,20 @@ declare namespace Phaser { */ projectionHeight: number; + /** + * A RenderTarget used by the BitmapMask Pipeline. + * + * This is the source, i.e. the masked Game Object itself. + */ + maskSource: Phaser.Renderer.WebGL.RenderTarget; + + /** + * A RenderTarget used by the BitmapMask Pipeline. + * + * This is the target, i.e. the framebuffer the masked objects are drawn to. + */ + maskTarget: Phaser.Renderer.WebGL.RenderTarget; + /** * Creates a new WebGLRenderingContext and initializes all internal state. * @param config The configuration object for the renderer. @@ -84420,6 +87169,23 @@ declare namespace Phaser { */ createFramebuffer(width: number, height: number, renderTexture: WebGLTexture, addDepthStencilBuffer?: boolean): WebGLFramebuffer; + /** + * 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 The BitmapMask instance that called beginMask. + * @param camera The camera rendering the current mask. + */ + beginBitmapMask(mask: Phaser.Display.Masks.BitmapMask, camera: Phaser.Cameras.Scene2D.Camera): void; + + /** + * 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 The BitmapMask instance that called beginMask. + * @param camera The camera rendering the current mask. + * @param bitmapMaskPipeline The BitmapMask Pipeline instance that is requesting the draw. + */ + drawBitmapMask(mask: Phaser.Display.Masks.BitmapMask, camera: Phaser.Cameras.Scene2D.Camera, bitmapMaskPipeline: Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline): void; + /** * Creates a WebGLProgram instance based on the given vertex and fragment shader source. * @@ -85193,1534 +87959,205 @@ 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 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 should use the string - * declaration `%count%` in your fragment shader source, which is used to set the number of - * `sampler2Ds` available. Also add `%getSampler%` so Phaser can inject the getSampler glsl function. - * This function can be used to get the pixel vec4 from the texture: - * - * `vec4 texture = getSampler(int(outTexId), outTexCoord);` - * - * This pipeline will automatically inject the getSampler function for you, should the value 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); - - /** - * A temporary Transform Matrix, re-used internally during batching by the - * Shape Game Objects. - */ - calcMatrix: Phaser.GameObjects.Components.TransformMatrix; - - /** - * 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; - - /** - * 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; - - } - - /** - * 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 SpriteFX Pipeline is a special kind of pipeline designed specifically for applying - * special effects to Sprites. Where-as the Post FX Pipeline applies an effect _after_ the - * object has been rendered, the Sprite FX Pipeline allows you to control the rendering of - * the object itself - passing it off to its own texture where multi-buffer compositing - * can take place. - * - * You can only use the SpriteFX Pipeline on the following types of Game Objects, or those - * that extend from them: - * - * Sprite - * Image - * Text - * TileSprite - * RenderTexture - * - * // TODO - Explain about the fbos and functions - */ - class SpriteFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - - /** - * A reference to the Draw Sprite Shader belonging to this Pipeline. - * - * This shader is used when the sprite is drawn to this fbo (or to the game if drawToFrame is false) - * - * This property is set during the `boot` method. - */ - drawSpriteShader: Phaser.Renderer.WebGL.WebGLShader; - - /** - * A reference to the Copy Shader belonging to this Pipeline. - * - * This shader is used when you call the `copySprite` method. - * - * This property is set during the `boot` method. - */ - copyShader: Phaser.Renderer.WebGL.WebGLShader; - - /** - * A reference to the Game Draw Shader belonging to this Pipeline. - * - * This shader draws the fbo to the game. - * - * This property is set during the `boot` method. - */ - gameShader: Phaser.Renderer.WebGL.WebGLShader; - - /** - * Raw byte buffer of vertices used specifically during the copySprite method. - */ - readonly quadVertexData: ArrayBuffer; - - /** - * The WebGLBuffer that holds the quadVertexData. - */ - readonly quadVertexBuffer: WebGLBuffer; - - /** - * Float32 view of the quad array buffer. - */ - quadVertexViewF32: Float32Array; - - /** - * The full-screen Render Target that the sprite is first drawn to. - */ - fsTarget: Phaser.Renderer.WebGL.RenderTarget; - - /** - * Handles the resizing of the quad vertex data. - * @param width The new width of the quad. - * @param height The new height of the quad. - */ - onResize(width: number, height: number): void; - - /** - * Takes a Sprite Game Object, or any object that extends it, and renders it via this pipeline. - * - * this method is a proxy for the MultiPipeline method of the same name. The actual rendering - * is redirected through to the `batchQuad` method in this pipeline. - * @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 the vertices data into the batch and flushes if full. - * - * Assumes 6 vertices in the following arrangement: - * - * ``` - * 0----3 - * |\ B| - * | \ | - * | \ | - * | A \| - * | \ - * 1----2 - * ``` - * - * Where x0 / y0 = 0, x1 / y1 = 1, x2 / y2 = 2 and x3 / y3 = 3 - * @param gameObject The Game Object, if any, drawing this quad. - * @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 u0 UV u0 value. - * @param v0 UV v0 value. - * @param u1 UV u1 value. - * @param v1 UV v1 value. - * @param tintTL The top-left tint color value. - * @param tintTR The top-right tint color value. - * @param tintBL The bottom-left tint color value. - * @param tintBR The bottom-right tint color value. - * @param tintEffect The tint effect for the shader to use. - * @param texture WebGLTexture that will be assigned to the current batch if a flush occurs. - */ - batchQuad(gameObject: Phaser.GameObjects.GameObject | null, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, u0: number, v0: number, u1: number, v1: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number | boolean, texture?: WebGLTexture): boolean; - - /** - * This callback is invoked when a sprite is drawn by this pipeline. - * - * It will fire after the shader has been set, but before the sprite has been drawn, - * so use it to set any additional uniforms you may need. - * - * Note: Manipulating the Sprite during this callback will _not_ change how it is drawn to the Render Target. - * @param gameObject The Sprite being drawn. - * @param target The Render Target the Sprite will be drawn to. - */ - onDrawSprite(gameObject: Phaser.GameObjects.Sprite, target: Phaser.Renderer.WebGL.RenderTarget): void; - - /** - * This callback is invoked when you call the `copySprite` method. - * - * It will fire after the shader has been set, but before the source target has been copied, - * so use it to set any additional uniforms you may need. - * - * Note: Manipulating the Sprite during this callback will _not_ change the Render Targets. - * @param source The source Render Target being copied from. - * @param target The target Render Target that will be copied to. - * @param gameObject The Sprite being copied. - */ - onCopySprite(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, gameObject: Phaser.GameObjects.Sprite): void; - - /** - * Copy the `source` Render Target to the `target` Render Target. - * - * No target 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. - * - * Calling this method will invoke the `onCopySprite` handler and will also call - * the `onFXCopy` callback on the Sprite. Both of these happen prior to the copy, allowing you - * to use them to set shader uniforms and other values. - * @param source The source Render Target being copied from. - * @param target The target Render Target that will be copied to. - * @param gameObject The Sprite being copied. - * @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. - * @param shader The shader to use to copy the target. Defaults to the `copyShader`. - */ - copySprite(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, gameObject: Phaser.GameObjects.Sprite, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean, shader?: Phaser.Renderer.WebGL.WebGLShader): 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; - - /** - * This method will copy the given Render Target to the game canvas using the `copyShader`. - * - * This applies the results of the copy shader during the draw. - * - * If you wish to copy the target without any effects see the `copyToGame` method instead. - * - * This method should be the final thing called in your pipeline. - * @param source The Render Target to draw to the game. - */ - drawToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; - - /** - * This method will copy the given Render Target to the game canvas using the `gameShader`. - * - * Unless you've changed it, the `gameShader` copies the target without modifying it, just - * ensuring it is placed in the correct location on the canvas. - * - * If you wish to draw the target with and apply the fragment shader at the same time, - * see the `drawToGame` method instead. - * - * This method should be the final thing called in your pipeline. - * @param source The Render Target to copy to the game. - */ - copyToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; - - /** - * This method is called by `drawToGame` and `copyToGame`. It takes the source Render Target - * and copies it back to the game canvas, or the next frame buffer in the stack, and should - * be considered the very last thing this pipeline does. - * - * You don't normally need to call this method, or override it, however it is left public - * should you wish to do so. - * - * Note that it does _not_ set a shader. You should do this yourself if invoking this. - * @param source The Render Target to draw to the game. - */ - bindAndDraw(source: Phaser.Renderer.WebGL.RenderTarget): void; - - /** - * This method is called every time the `batchSprite` method is called and is passed a - * reference to the current render target. - * - * If you override this method, then it should make sure it calls either the - * `drawToGame` or `copyToGame` methods as the final thing it does. However, you can do as - * much additional processing as you like prior to this. - * @param target The Render Target to draw to the game. - * @param swapTarget The Swap Render Target, useful for double-buffer effects. - * @param altSwapTarget The Swap Render Target, useful for double-buffer effects. - */ - onDraw(target: Phaser.Renderer.WebGL.RenderTarget, swapTarget?: Phaser.Renderer.WebGL.RenderTarget, altSwapTarget?: Phaser.Renderer.WebGL.RenderTarget): void; - - /** - * Set the UV values for the 6 vertices that make up the quad used by the copy shader. - * - * 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 copy shaders - * 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; - - /** - * Resets the quad vertice UV values to their default settings. - * - * The quad is used by the copy shader in this pipeline. - */ - resetUVs(): void; - - /** - * Destroys all shader instances, removes all object references and nulls all external references. - */ - destroy(): this; - - } - - /** - * 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. - * @param flipY Flip the UV on the Y axis before drawing? Default false. - */ - blitFrame(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean, flipY?: 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: string; + + /** + * The Scale Manager tried to enter fullscreen mode but failed. + */ + const FULLSCREEN_FAILED: string; + + /** + * The Scale Manager tried to enter fullscreen mode, but it is unsupported by the browser. + */ + const FULLSCREEN_UNSUPPORTED: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + } + /** * The Scale Manager handles the scaling, resizing and alignment of the game canvas. * @@ -87187,10 +88624,11 @@ declare namespace Phaser { onFullScreenError(): void; /** - * Get Rectange of visible area, this Rectange does NOT factor in camera scroll. + * Get Rectange of visible area. + * @param camera The camera this viewport is respond upon. * @param out The Rectangle of visible area. */ - getViewPort(out?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle; + getViewPort(camera?: Phaser.Cameras.Scene2D.Camera, out?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle; /** * Internal method, called automatically by the game step. @@ -87258,182 +88696,6 @@ 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. @@ -87535,204 +88797,386 @@ 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 The scene key or 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.events.on('addedtoscene', listener)`. + */ + const ADDED_TO_SCENE: string; + + /** + * 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.events.on('boot', listener)`. + */ + const BOOT: string; + + /** + * 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.events.on('create', listener)`. + */ + const CREATE: string; + + /** + * 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.events.on('destroy', listener)`. + * + * You should destroy any resources that may be in use by your Scene in this event handler. + */ + const DESTROY: string; + + /** + * 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.events.on('pause', listener)`. + */ + const PAUSE: string; + + /** + * 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.events.on('postupdate', listener)`. + * + * A Scene will only run its step if it is active. + */ + const POST_UPDATE: string; + + /** + * 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.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: string; + + /** + * 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.events.on('preupdate', listener)`. + * + * A Scene will only run its step if it is active. + */ + const PRE_UPDATE: string; + + /** + * 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.events.on('ready', listener)`. + */ + const READY: string; + + /** + * 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.events.on('removedfromscene', listener)`. + */ + const REMOVED_FROM_SCENE: string; + + /** + * 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.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: string; + + /** + * 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.events.on('resume', listener)`. + */ + const RESUME: string; + + /** + * 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.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: string; + + /** + * 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.events.on('sleep', listener)`. + */ + const SLEEP: string; + + /** + * 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.events.on('start', listener)`. + */ + const START: string; + + /** + * 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.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: string; + + /** + * 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.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: string; + + /** + * 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.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: string; + + /** + * 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.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: string; + + /** + * 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.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: string; + + /** + * 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 and the Scene is in a Running state, otherwise this is skipped. + * 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.events.on('update', listener)`. + * + * A Scene will only run its step if it is active. + */ + const UPDATE: string; + + /** + * 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.events.on('wake', listener)`. + */ + const WAKE: string; + + } + /** * 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. @@ -87797,6 +89241,14 @@ declare namespace Phaser { */ customViewports: number; + /** + * This system Scene is created during `bootQueue` and is a default + * empty Scene that lives outside of the Scene list, but can be used + * by plugins and managers that need access to a live Scene, without + * being tied to one. + */ + systemScene: Phaser.Scenes.Scene; + /** * Process the Scene operations queue. */ @@ -87820,7 +89272,7 @@ declare namespace Phaser { * @param autoStart If `true` the Scene will be started immediately after being added. Default false. * @param data Optional data object. This will be set as `Scene.settings.data` and passed to `Scene.init`, and `Scene.create`. */ - add(key: string, sceneConfig: SceneType, autoStart?: boolean, data?: object): Phaser.Scene | null; + add(key: string, sceneConfig: Phaser.Types.Scenes.SceneType, autoStart?: boolean, data?: object): Phaser.Scene | null; /** * Removes a Scene from the SceneManager. @@ -88140,7 +89592,7 @@ declare namespace Phaser { * @param autoStart If `true` the Scene will be started immediately after being added. Default false. * @param data Optional data object. This will be set as `Scene.settings.data` and passed to `Scene.init`, and `Scene.create`. */ - add(key: string, sceneConfig: SceneType, autoStart?: boolean, data?: object): Phaser.Scene | null; + add(key: string, sceneConfig: Phaser.Types.Scenes.SceneType, autoStart?: boolean, data?: object): Phaser.Scene | null; /** * Launch the given Scene and run it in parallel with this one. @@ -88676,384 +90128,202 @@ 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 { /** - * Scene state. + * + * @param config The scene key or scene specific configuration settings. */ - var PENDING: number; + constructor(config?: string | Phaser.Types.Scenes.SettingsConfig); /** - * Scene state. + * The Scene Systems. You must never overwrite this property, or all hell will break lose. */ - var INIT: number; + sys: Phaser.Scenes.Systems; /** - * Scene state. + * A reference to the Phaser.Game instance. + * + * This property will only be available if defined in the Scene Injection Map. */ - var START: number; + game: Phaser.Game; /** - * Scene state. + * A reference to the global Animation Manager. + * + * This property will only be available if defined in the Scene Injection Map. */ - var LOADING: number; + anims: Phaser.Animations.AnimationManager; /** - * Scene state. + * A reference to the global Cache. + * + * This property will only be available if defined in the Scene Injection Map. */ - var CREATING: number; + cache: Phaser.Cache.CacheManager; /** - * Scene state. + * A reference to the global Data Manager. + * + * This property will only be available if defined in the Scene Injection Map. */ - var RUNNING: number; + registry: Phaser.Data.DataManager; /** - * Scene state. + * A reference to the Sound Manager. + * + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. */ - var PAUSED: number; + sound: Phaser.Sound.NoAudioSoundManager | Phaser.Sound.HTML5AudioSoundManager | Phaser.Sound.WebAudioSoundManager; /** - * Scene state. + * A reference to the Texture Manager. + * + * This property will only be available if defined in the Scene Injection Map. */ - var SLEEPING: number; + textures: Phaser.Textures.TextureManager; /** - * Scene state. + * A Scene specific Event Emitter. + * + * This property will only be available if defined in the Scene Injection Map. */ - var SHUTDOWN: number; + events: Phaser.Events.EventEmitter; /** - * Scene state. + * The Scene Camera Manager. + * + * This property will only be available if defined in the Scene Injection Map. */ - var DESTROYED: number; + cameras: Phaser.Cameras.Scene2D.CameraManager; - 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.events.on('addedtoscene', listener)`. - */ - const ADDED_TO_SCENE: any; + /** + * The Scene Game Object Factory. + * + * This property will only be available if defined in the Scene Injection Map. + */ + add: Phaser.GameObjects.GameObjectFactory; - /** - * 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.events.on('boot', listener)`. - */ - const BOOT: 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 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.events.on('create', listener)`. - */ - const CREATE: 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 Systems Destroy Event. - * - * This event is dispatched by a Scene during the Scene Systems destroy process. - * - * Listen to it from a Scene using `this.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 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 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.events.on('pause', listener)`. - */ - const PAUSE: 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 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.events.on('postupdate', listener)`. - * - * A Scene will only run its step if it is active. - */ - const POST_UPDATE: 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 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.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 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 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.events.on('preupdate', listener)`. - * - * A Scene will only run its step if it is active. - */ - const PRE_UPDATE: 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 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.events.on('ready', listener)`. - */ - const READY: 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 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.events.on('removedfromscene', listener)`. - */ - const REMOVED_FROM_SCENE: 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 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.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 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 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.events.on('resume', listener)`. - */ - const RESUME: 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 Shutdown Event. - * - * This event is dispatched by a Scene during the Scene Systems shutdown process. - * - * Listen to it from a Scene using `this.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 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 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.events.on('sleep', listener)`. - */ - const SLEEP: 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 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.events.on('start', listener)`. - */ - const START: 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 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.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; + /** + * 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 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.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.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.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.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 and the Scene is in a Running state, otherwise this is skipped. - * 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.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.events.on('wake', listener)`. - */ - const WAKE: 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; } @@ -89390,14 +90660,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; - namespace Events { /** * The Sound Complete Event. @@ -89412,7 +90674,7 @@ declare namespace Phaser { * music.play(); * ``` */ - const COMPLETE: any; + const COMPLETE: string; /** * The Audio Data Decoded All Event. @@ -89430,7 +90692,7 @@ declare namespace Phaser { * this.sound.decodeAudio([ audioFiles ]); * ``` */ - const DECODED_ALL: any; + const DECODED_ALL: string; /** * The Audio Data Decoded Event. @@ -89444,7 +90706,7 @@ declare namespace Phaser { * this.sound.decodeAudio(key, audioData); * ``` */ - const DECODED: any; + const DECODED: string; /** * The Sound Destroy Event. @@ -89460,7 +90722,7 @@ declare namespace Phaser { * music.destroy(); * ``` */ - const DESTROY: any; + const DESTROY: string; /** * The Sound Detune Event. @@ -89476,7 +90738,7 @@ declare namespace Phaser { * music.setDetune(200); * ``` */ - const DETUNE: any; + const DETUNE: string; /** * The Sound Manager Global Detune Event. @@ -89487,7 +90749,7 @@ declare namespace Phaser { * * Listen to it from a Scene using: `this.sound.on('rate', listener)`. */ - const GLOBAL_DETUNE: any; + const GLOBAL_DETUNE: string; /** * The Sound Manager Global Mute Event. @@ -89497,7 +90759,7 @@ declare namespace Phaser { * * Listen to it from a Scene using: `this.sound.on('mute', listener)`. */ - const GLOBAL_MUTE: any; + const GLOBAL_MUTE: string; /** * The Sound Manager Global Rate Event. @@ -89508,7 +90770,7 @@ declare namespace Phaser { * * Listen to it from a Scene using: `this.sound.on('rate', listener)`. */ - const GLOBAL_RATE: any; + const GLOBAL_RATE: string; /** * The Sound Manager Global Volume Event. @@ -89518,7 +90780,7 @@ declare namespace Phaser { * * Listen to it from a Scene using: `this.sound.on('volume', listener)`. */ - const GLOBAL_VOLUME: any; + const GLOBAL_VOLUME: string; /** * The Sound Looped Event. @@ -89536,7 +90798,7 @@ declare namespace Phaser { * * This is not to be confused with the [LOOP]{@linkcode Phaser.Sound.Events#event:LOOP} event, which only emits when the loop state of a Sound is changed. */ - const LOOPED: any; + const LOOPED: string; /** * The Sound Loop Event. @@ -89553,7 +90815,7 @@ declare namespace Phaser { * * This is not to be confused with the [LOOPED]{@linkcode Phaser.Sound.Events#event:LOOPED} event, which emits each time a Sound loops during playback. */ - const LOOP: any; + const LOOP: string; /** * The Sound Mute Event. @@ -89569,7 +90831,7 @@ declare namespace Phaser { * music.setMute(true); * ``` */ - const MUTE: any; + const MUTE: string; /** * The Sound Pan Event. @@ -89585,7 +90847,7 @@ declare namespace Phaser { * sound.setPan(0.5); * ``` */ - const PAN: any; + const PAN: string; /** * The Pause All Sounds Event. @@ -89596,7 +90858,7 @@ declare namespace Phaser { * * Listen to it from a Scene using: `this.sound.on('pauseall', listener)`. */ - const PAUSE_ALL: any; + const PAUSE_ALL: string; /** * The Sound Pause Event. @@ -89612,7 +90874,7 @@ declare namespace Phaser { * music.pause(); * ``` */ - const PAUSE: any; + const PAUSE: string; /** * The Sound Play Event. @@ -89627,7 +90889,7 @@ declare namespace Phaser { * music.play(); * ``` */ - const PLAY: any; + const PLAY: string; /** * The Sound Rate Change Event. @@ -89643,7 +90905,7 @@ declare namespace Phaser { * music.setRate(0.5); * ``` */ - const RATE: any; + const RATE: string; /** * The Resume All Sounds Event. @@ -89654,7 +90916,7 @@ declare namespace Phaser { * * Listen to it from a Scene using: `this.sound.on('resumeall', listener)`. */ - const RESUME_ALL: any; + const RESUME_ALL: string; /** * The Sound Resume Event. @@ -89671,7 +90933,7 @@ declare namespace Phaser { * music.resume(); * ``` */ - const RESUME: any; + const RESUME: string; /** * The Sound Seek Event. @@ -89687,7 +90949,7 @@ declare namespace Phaser { * music.setSeek(5000); * ``` */ - const SEEK: any; + const SEEK: string; /** * The Stop All Sounds Event. @@ -89698,7 +90960,7 @@ declare namespace Phaser { * * Listen to it from a Scene using: `this.sound.on('stopall', listener)`. */ - const STOP_ALL: any; + const STOP_ALL: string; /** * The Sound Stop Event. @@ -89714,7 +90976,7 @@ declare namespace Phaser { * music.stop(); * ``` */ - const STOP: any; + const STOP: string; /** * The Sound Manager Unlocked Event. @@ -89725,7 +90987,7 @@ declare namespace Phaser { * * Listen to it from a Scene using: `this.sound.on('unlocked', listener)`. */ - const UNLOCKED: any; + const UNLOCKED: string; /** * The Sound Volume Event. @@ -89741,7 +91003,7 @@ declare namespace Phaser { * music.setVolume(0.5); * ``` */ - const VOLUME: any; + const VOLUME: string; } @@ -90459,6 +91721,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; + /** * Web Audio API implementation of the sound. */ @@ -90854,6 +92124,31 @@ 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: string; + + /** + * 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: string; + + } + /** * List is a generic implementation of an ordered list which contains utility methods for retrieving, manipulating, and iterating items. */ @@ -91783,31 +93078,6 @@ 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 { @@ -92027,6 +93297,707 @@ declare namespace Phaser { } + /** + * Filter Types. + */ + enum FilterMode { + /** + * Linear filter type. + */ + LINEAR, + /** + * Nearest neighbor filter type. + */ + NEAREST, + } + + /** + * A Dynamic Texture is a special texture that allows you to draw textures, frames and most kind of + * Game Objects directly to it. + * + * You can take many complex objects and draw them to this one texture, which can then be used as the + * base texture for other Game Objects, such as Sprites. Should you then update this texture, all + * Game Objects using it will instantly be updated as well, reflecting the changes immediately. + * + * It's a powerful way to generate dynamic textures at run-time that are WebGL friendly and don't invoke + * expensive GPU uploads on each change. + * + * ```js + * const t = this.textures.addDynamicTexture('player', 64, 128); + * // draw objects to t + * this.add.sprite(x, y, 'player'); + * ``` + * + * Because this is a standard Texture within Phaser, you can add frames to it, meaning you can use it + * to generate sprite sheets, texture atlases or tile sets. + * + * Under WebGL, a FrameBuffer, which is what this Dynamic Texture uses internally, cannot be anti-aliased. + * This means that when drawing objects such as Shapes or Graphics instances to this texture, they may appear + * to be drawn with no aliasing around the edges. This is a technical limitation of WebGL1. To get around it, + * create your shape as a texture in an art package, then draw that to this texture. + * + * Based on the assumption that you will be using this Dynamic Texture as a source for Sprites, it will + * automatically invert any drawing done to it on the y axis. If you do not require this, please call the + * `setIsSpriteTexture()` method and pass it `false` as its parameter. Do this before you start drawing + * to this texture, otherwise you will get vertically inverted frames under WebGL. This isn't required + * for Canvas. + */ + class DynamicTexture extends Phaser.Textures.Texture { + /** + * + * @param manager A reference to the Texture Manager this Texture belongs to. + * @param key The unique string-based key of this Texture. + * @param width The width of this Dymamic Texture in pixels. Defaults to 256 x 256. Default 256. + * @param height The height of this Dymamic Texture in pixels. Defaults to 256 x 256. Default 256. + */ + constructor(manager: Phaser.Textures.TextureManager, key: string, width?: number, height?: number); + + /** + * The internal data type of this object. + */ + readonly type: string; + + /** + * A reference to either the Canvas or WebGL Renderer that the Game instance is using. + */ + renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + + /** + * This flag is set to 'true' during `beginDraw` and reset to 'false` in `endDraw`, + * allowing you to determine if this Dynamic Texture is batch drawing, or not. + */ + readonly isDrawing: boolean; + + /** + * A reference to the Rendering Context belonging to the Canvas Element this Dynamic Texture is drawing to. + */ + canvas: HTMLCanvasElement; + + /** + * Is this Dynamic Texture dirty or not? If not it won't spend time clearing or filling itself. + */ + dirty: boolean; + + /** + * Is this Dynamic Texture being used as the base texture for a Sprite Game Object? + * + * This is enabled by default, as we expect that will be the core use for Dymamic Textures. + * + * However, to disable it, call `RenderTexture.setIsSpriteTexture(false)`. + * + * You should do this _before_ drawing to this texture, so that it correctly + * inverses the frames for WebGL rendering. Not doing so will result in vertically flipped frames. + * + * This property is used in the `endDraw` method. + */ + isSpriteTexture: boolean; + + /** + * An internal Camera that can be used to move around this Dynamic Texture. + * + * Control it just like you would any Scene Camera. The difference is that it only impacts + * the placement of Game Objects that you then draw to this texture. + * + * You can scroll, zoom and rotate this Camera. + */ + camera: Phaser.Cameras.Scene2D.BaseCamera; + + /** + * The Render Target that belongs to this Dynamic Texture. + * + * A Render Target encapsulates a framebuffer and texture for the WebGL Renderer. + * + * This property remains `null` under Canvas. + */ + renderTarget: Phaser.Renderer.WebGL.RenderTarget; + + /** + * A reference to the WebGL Single Pipeline. + * + * This property remains `null` under Canvas. + */ + pipeline: Phaser.Renderer.WebGL.Pipelines.SinglePipeline; + + /** + * Resizes this Dynamic Texture to the new dimensions given. + * + * In WebGL it will destroy and then re-create the frame buffer being used by this Dynamic Texture. + * In Canvas it will resize the underlying canvas DOM element. + * + * Both approaches will erase everything currently drawn to this texture. + * + * If the dimensions given are the same as those already being used, calling this method will do nothing. + * @param width The new width of this Dynamic Texture. + * @param height The new height of this Dynamic Texture. If not specified, will be set the same as the `width`. Default width. + */ + setSize(width: number, height?: number): this; + + /** + * If you are planning on using this Render Texture as a base texture for Sprite + * Game Objects, then you should call this method with a value of `true` before + * drawing anything to it, otherwise you will get inverted frames in WebGL. + * @param value Is this Render Target being used as a Sprite Texture, or not? + */ + setIsSpriteTexture(value: boolean): this; + + /** + * Fills this Dynamic Texture with the given color. + * + * By default it will fill the entire texture, however you can set it to fill a specific + * rectangular area by using the x, y, width and height arguments. + * + * The color should be given in hex format, i.e. 0xff0000 for red, 0x00ff00 for green, etc. + * @param rgb The color to fill this Dynamic Texture with, such as 0xff0000 for red. + * @param alpha The alpha value used by the fill. Default 1. + * @param x The left coordinate of the fill rectangle. Default 0. + * @param y The top coordinate of the fill rectangle. Default 0. + * @param width The width of the fill rectangle. Default this.width. + * @param height The height of the fill rectangle. Default this.height. + */ + fill(rgb: number, alpha?: number, x?: number, y?: number, width?: number, height?: number): this; + + /** + * Fully clears this Dynamic Texture, erasing everything from it and resetting it back to + * a blank, transparent, texture. + */ + clear(): this; + + /** + * Takes the given texture key and frame and then stamps it at the given + * x and y coordinates. You can use the optional 'config' argument to provide + * lots more options about how the stamp is applied, including the alpha, + * tint, angle, scale and origin. + * + * By default, the frame will stamp on the x/y coordinates based on its center. + * + * If you wish to stamp from the top-left, set the config `originX` and + * `originY` properties both to zero. + * @param key The key of the texture to be used, as stored in the Texture Manager. + * @param frame The name or index of the frame within the Texture. Set to `null` to skip this argument if not required. + * @param x The x position to draw the frame at. Default 0. + * @param y The y position to draw the frame at. Default 0. + * @param config The stamp configuration object, allowing you to set the alpha, tint, angle, scale and origin of the stamp. + */ + stamp(key: string, frame?: string | number, x?: number, y?: number, config?: Phaser.Types.Textures.StampConfig): this; + + /** + * Draws the given object, or an array of objects, to this Dynamic Texture using a blend mode of ERASE. + * This has the effect of erasing any filled pixels present in the objects from this texture. + * + * It can accept any of the following: + * + * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. + * * Tilemap Layers. + * * A Group. The contents of which will be iterated and drawn in turn. + * * A Container. The contents of which will be iterated fully, and drawn in turn. + * * A Scene Display List. Pass in `Scene.children` to draw the whole list. + * * Another Dynamic Texture, or a Render Texture. + * * A Texture Frame instance. + * * A string. This is used to look-up the texture from the Texture Manager. + * + * Note: You cannot erase a Dynamic Texture from itself. + * + * If passing in a Group or Container it will only draw children that return `true` + * when their `willRender()` method is called. I.e. a Container with 10 children, + * 5 of which have `visible=false` will only draw the 5 visible ones. + * + * If passing in an array of Game Objects it will draw them all, regardless if + * they pass a `willRender` check or not. + * + * You can pass in a string in which case it will look for a texture in the Texture + * Manager matching that string, and draw the base frame. + * + * You can pass in the `x` and `y` coordinates to draw the objects at. The use of + * the coordinates differ based on what objects are being drawn. If the object is + * a Group, Container or Display List, the coordinates are _added_ to the positions + * of the children. For all other types of object, the coordinates are exact. + * + * Calling this method causes the WebGL batch to flush, so it can write the texture + * data to the framebuffer being used internally. The batch is flushed at the end, + * after the entries have been iterated. So if you've a bunch of objects to draw, + * try and pass them in an array in one single call, rather than making lots of + * separate calls. + * + * If you are not planning on using this Dynamic Texture as a base texture for Sprite + * Game Objects, then you should set `DynamicTexture.isSpriteTexture = false` before + * calling this method, otherwise you will get vertically inverted frames in WebGL. + * @param entries Any renderable Game Object, or Group, Container, Display List, Render Texture, Texture Frame, or an array of any of these. + * @param x The x position to draw the Frame at, or the offset applied to the object. Default 0. + * @param y The y position to draw the Frame at, or the offset applied to the object. Default 0. + */ + erase(entries: any, x?: number, y?: number): this; + + /** + * Draws the given object, or an array of objects, to this Dynamic Texture. + * + * It can accept any of the following: + * + * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. + * * Tilemap Layers. + * * A Group. The contents of which will be iterated and drawn in turn. + * * A Container. The contents of which will be iterated fully, and drawn in turn. + * * A Scene Display List. Pass in `Scene.children` to draw the whole list. + * * Another Dynamic Texture, or a Render Texture. + * * A Texture Frame instance. + * * A string. This is used to look-up the texture from the Texture Manager. + * + * Note 1: You cannot draw a Dynamic Texture to itself. + * + * Note 2: For Game Objects that have Post FX Pipelines, the pipeline _cannot_ be + * used when drawn to this texture. + * + * If passing in a Group or Container it will only draw children that return `true` + * when their `willRender()` method is called. I.e. a Container with 10 children, + * 5 of which have `visible=false` will only draw the 5 visible ones. + * + * If passing in an array of Game Objects it will draw them all, regardless if + * they pass a `willRender` check or not. + * + * You can pass in a string in which case it will look for a texture in the Texture + * Manager matching that string, and draw the base frame. If you need to specify + * exactly which frame to draw then use the method `drawFrame` instead. + * + * You can pass in the `x` and `y` coordinates to draw the objects at. The use of + * the coordinates differ based on what objects are being drawn. If the object is + * a Group, Container or Display List, the coordinates are _added_ to the positions + * of the children. For all other types of object, the coordinates are exact. + * + * The `alpha` and `tint` values are only used by Texture Frames. + * Game Objects use their own alpha and tint values when being drawn. + * + * Calling this method causes the WebGL batch to flush, so it can write the texture + * data to the framebuffer being used internally. The batch is flushed at the end, + * after the entries have been iterated. So if you've a bunch of objects to draw, + * try and pass them in an array in one single call, rather than making lots of + * separate calls. + * + * If you are not planning on using this Dynamic Texture as a base texture for Sprite + * Game Objects, then you should set `DynamicTexture.isSpriteTexture = false` before + * calling this method, otherwise you will get vertically inverted frames in WebGL. + * @param entries Any renderable Game Object, or Group, Container, Display List, other Render Texture, Texture Frame or an array of any of these. + * @param x The x position to draw the Frame at, or the offset applied to the object. Default 0. + * @param y The y position to draw the Frame at, or the offset applied to the object. Default 0. + * @param alpha The alpha value. Only used when drawing Texture Frames to this texture. Game Objects use their own alpha. Default 1. + * @param tint The tint color value. Only used when drawing Texture Frames to this texture. Game Objects use their own tint. WebGL only. Default 0xffffff. + */ + draw(entries: any, x?: number, y?: number, alpha?: number, tint?: number): this; + + /** + * Draws the Texture Frame to the Render Texture at the given position. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * ```javascript + * var rt = this.add.renderTexture(0, 0, 800, 600); + * rt.drawFrame(key, frame); + * ``` + * + * You can optionally provide a position, alpha and tint value to apply to the frame + * before it is drawn. + * + * Calling this method will cause a batch flush, so if you've got a stack of things to draw + * in a tight loop, try using the `draw` method instead. + * + * If you need to draw a Sprite to this Render Texture, use the `draw` method instead. + * + * If you are not planning on using this Dynamic Texture as a base texture for Sprite + * Game Objects, then you should set `DynamicTexture.isSpriteTexture = false` before + * calling this method, otherwise you will get vertically inverted frames in WebGL. + * @param key The key of the texture to be used, as stored in the Texture Manager. + * @param frame The name or index of the frame within the Texture. Set to `null` to skip this argument if not required. + * @param x The x position to draw the frame at. Default 0. + * @param y The y position to draw the frame at. Default 0. + * @param alpha The alpha value. Only used when drawing Texture Frames to this texture. Default 1. + * @param tint The tint color value. Only used when drawing Texture Frames to this texture. WebGL only. Default 0xffffff. + */ + drawFrame(key: string, frame?: string | number, x?: number, y?: number, alpha?: number, tint?: number): this; + + /** + * Takes the given Texture Frame and draws it to this Dynamic Texture as a fill pattern, + * i.e. in a grid-layout based on the frame dimensions. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * You can optionally provide a position, width, height, alpha and tint value to apply to + * the frames before they are drawn. The position controls the top-left where the repeating + * fill will start from. The width and height control the size of the filled area. + * + * The position can be negative if required, but the dimensions cannot. + * + * Calling this method will cause a batch flush by default. Use the `skipBatch` argument + * to disable this if this call is part of a larger batch draw. + * + * If you are not planning on using this Dynamic Texture as a base texture for Sprite + * Game Objects, then you should set `DynamicTexture.isSpriteTexture = false` before + * calling this method, otherwise you will get vertically inverted frames in WebGL. + * @param key The key of the texture to be used, as stored in the Texture Manager. + * @param frame The name or index of the frame within the Texture. Set to `null` to skip this argument if not required. + * @param x The x position to start drawing the frames from (can be negative to offset). Default 0. + * @param y The y position to start drawing the frames from (can be negative to offset). Default 0. + * @param width The width of the area to repeat the frame within. Defaults to the width of this Dynamic Texture. Default this.width. + * @param height The height of the area to repeat the frame within. Defaults to the height of this Dynamic Texture. Default this.height. + * @param alpha The alpha to use. Defaults to 1, no alpha. Default 1. + * @param tint WebGL only. The tint color to use. Leave as undefined, or 0xffffff to have no tint. Default 0xffffff. + * @param skipBatch Skip beginning and ending a batch with this call. Use if this is part of a bigger batched draw. Default false. + */ + repeat(key: string, frame?: string | number, x?: number, y?: number, width?: number, height?: number, alpha?: number, tint?: number, skipBatch?: boolean): this; + + /** + * Use this method if you need to batch draw a large number of Game Objects to + * this Dynamic Texture in a single pass, or on a frequent basis. This is especially + * useful under WebGL, however, if your game is using Canvas only, it will not make + * any speed difference in that situation. + * + * This method starts the beginning of a batched draw, unless one is already open. + * + * Batched drawing is faster than calling `draw` in loop, but you must be careful + * to manage the flow of code and remember to call `endDraw()` when you're finished. + * + * If you don't need to draw large numbers of objects it's much safer and easier + * to use the `draw` method instead. + * + * The flow should be: + * + * ```javascript + * // Call once: + * DynamicTexture.beginDraw(); + * + * // repeat n times: + * DynamicTexture.batchDraw(); + * // or + * DynamicTexture.batchDrawFrame(); + * + * // Call once: + * DynamicTexture.endDraw(); + * ``` + * + * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you + * have started a batch. Also, be very careful not to destroy this Dynamic Texture while the + * batch is still open. Doing so will cause a run-time error in the WebGL Renderer. + * + * You can use the `DynamicTexture.isDrawing` boolean property to tell if a batch is + * currently open, or not. + */ + beginDraw(): this; + + /** + * Use this method if you have already called `beginDraw` and need to batch + * draw a large number of objects to this Dynamic Texture. + * + * This method batches the drawing of the given objects to this texture, + * without causing a WebGL bind or batch flush for each one. + * + * It is faster than calling `draw`, but you must be careful to manage the + * flow of code and remember to call `endDraw()`. If you don't need to draw large + * numbers of objects it's much safer and easier to use the `draw` method instead. + * + * The flow should be: + * + * ```javascript + * // Call once: + * DynamicTexture.beginDraw(); + * + * // repeat n times: + * DynamicTexture.batchDraw(); + * // or + * DynamicTexture.batchDrawFrame(); + * + * // Call once: + * DynamicTexture.endDraw(); + * ``` + * + * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you + * have started a batch. Also, be very careful not to destroy this Dynamic Texture while the + * batch is still open. Doing so will cause a run-time error in the WebGL Renderer. + * + * You can use the `DynamicTexture.isDrawing` boolean property to tell if a batch is + * currently open, or not. + * + * This method can accept any of the following: + * + * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. + * * Tilemap Layers. + * * A Group. The contents of which will be iterated and drawn in turn. + * * A Container. The contents of which will be iterated fully, and drawn in turn. + * * A Scene's Display List. Pass in `Scene.children` to draw the whole list. + * * Another Dynamic Texture or Render Texture. + * * A Texture Frame instance. + * * A string. This is used to look-up a texture from the Texture Manager. + * + * Note: You cannot draw a Dynamic Texture to itself. + * + * If passing in a Group or Container it will only draw children that return `true` + * when their `willRender()` method is called. I.e. a Container with 10 children, + * 5 of which have `visible=false` will only draw the 5 visible ones. + * + * If passing in an array of Game Objects it will draw them all, regardless if + * they pass a `willRender` check or not. + * + * You can pass in a string in which case it will look for a texture in the Texture + * Manager matching that string, and draw the base frame. If you need to specify + * exactly which frame to draw then use the method `drawFrame` instead. + * + * You can pass in the `x` and `y` coordinates to draw the objects at. The use of + * the coordinates differ based on what objects are being drawn. If the object is + * a Group, Container or Display List, the coordinates are _added_ to the positions + * of the children. For all other types of object, the coordinates are exact. + * + * The `alpha` and `tint` values are only used by Texture Frames. + * Game Objects use their own alpha and tint values when being drawn. + * @param entries Any renderable Game Object, or Group, Container, Display List, other Dynamic or Texture, Texture Frame or an array of any of these. + * @param x The x position to draw the Frame at, or the offset applied to the object. Default 0. + * @param y The y position to draw the Frame at, or the offset applied to the object. Default 0. + * @param alpha The alpha value. Only used when drawing Texture Frames to this texture. Game Objects use their own alpha. Default 1. + * @param tint The tint color value. Only used when drawing Texture Frames to this texture. Game Objects use their own tint. WebGL only. Default 0xffffff. + */ + batchDraw(entries: any, x?: number, y?: number, alpha?: number, tint?: number): this; + + /** + * Use this method if you have already called `beginDraw` and need to batch + * draw a large number of texture frames to this Dynamic Texture. + * + * This method batches the drawing of the given frames to this Dynamic Texture, + * without causing a WebGL bind or batch flush for each one. + * + * It is faster than calling `drawFrame`, but you must be careful to manage the + * flow of code and remember to call `endDraw()`. If you don't need to draw large + * numbers of frames it's much safer and easier to use the `drawFrame` method instead. + * + * The flow should be: + * + * ```javascript + * // Call once: + * DynamicTexture.beginDraw(); + * + * // repeat n times: + * DynamicTexture.batchDraw(); + * // or + * DynamicTexture.batchDrawFrame(); + * + * // Call once: + * DynamicTexture.endDraw(); + * ``` + * + * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you + * have started a batch. Also, be very careful not to destroy this Dynamic Texture while the + * batch is still open. Doing so will cause a run-time error in the WebGL Renderer. + * + * You can use the `DynamicTexture.isDrawing` boolean property to tell if a batch is + * currently open, or not. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * You can optionally provide a position, alpha and tint value to apply to the frame + * before it is drawn. + * @param key The key of the texture to be used, as stored in the Texture Manager. + * @param frame The name or index of the frame within the Texture. + * @param x The x position to draw the frame at. Default 0. + * @param y The y position to draw the frame at. Default 0. + * @param alpha The alpha value. Only used when drawing Texture Frames to this texture. Game Objects use their own alpha. Default 1. + * @param tint The tint color value. Only used when drawing Texture Frames to this texture. Game Objects use their own tint. WebGL only. Default 0xffffff. + */ + batchDrawFrame(key: string, frame?: string | number, x?: number, y?: number, alpha?: number, tint?: number): this; + + /** + * Use this method to finish batch drawing to this Dynamic Texture. + * + * Doing so will stop the WebGL Renderer from capturing draws and then blit the + * framebuffer to the Render Target owned by this texture. + * + * Calling this method without first calling `beginDraw` will have no effect. + * + * Batch drawing is faster than calling `draw`, but you must be careful to manage the + * flow of code and remember to call `endDraw()` when you're finished. + * + * If you don't need to draw large numbers of objects it's much safer and easier + * to use the `draw` method instead. + * + * The flow should be: + * + * ```javascript + * // Call once: + * DynamicTexture.beginDraw(); + * + * // repeat n times: + * DynamicTexture.batchDraw(); + * // or + * DynamicTexture.batchDrawFrame(); + * + * // Call once: + * DynamicTexture.endDraw(); + * ``` + * + * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you + * have started a batch. Also, be very careful not to destroy this Dynamic Texture while the + * batch is still open. Doing so will cause a run-time error in the WebGL Renderer. + * + * You can use the `DynamicTexture.isDrawing` boolean property to tell if a batch is + * currently open, or not. + * @param erase Draws all objects in this batch using a blend mode of ERASE. This has the effect of erasing any filled pixels in the objects being drawn. Default false. + */ + endDraw(erase?: boolean): this; + + /** + * Takes a snapshot of the given area of this Dynamic Texture. + * + * The snapshot is taken immediately, but the results are returned via the given callback. + * + * To capture the whole Dynamic Texture see the `snapshot` method. + * To capture just a specific pixel, see the `snapshotPixel` method. + * + * Snapshots work by using the WebGL `readPixels` feature to grab every pixel from the frame buffer + * into an ArrayBufferView. It then parses this, copying the contents to a temporary Canvas and finally + * creating an Image object from it, which is the image returned to the callback provided. + * + * All in all, this is a computationally expensive and blocking process, which gets more expensive + * the larger the resolution this Dynamic Texture has, so please be careful how you employ this in your game. + * @param x The x coordinate to grab from. + * @param y The y coordinate to grab from. + * @param width The width of the area to grab. + * @param height The height of the area to grab. + * @param callback The Function to invoke after the snapshot image is created. + * @param type The format of the image to create, usually `image/png` or `image/jpeg`. Default 'image/png'. + * @param encoderOptions The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. Default 0.92. + */ + snapshotArea(x: number, y: number, width: number, height: number, callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback, type?: string, encoderOptions?: number): this; + + /** + * Takes a snapshot of the whole of this Dynamic Texture. + * + * The snapshot is taken immediately, but the results are returned via the given callback. + * + * To capture a portion of this Dynamic Texture see the `snapshotArea` method. + * To capture just a specific pixel, see the `snapshotPixel` method. + * + * Snapshots work by using the WebGL `readPixels` feature to grab every pixel from the frame buffer + * into an ArrayBufferView. It then parses this, copying the contents to a temporary Canvas and finally + * creating an Image object from it, which is the image returned to the callback provided. + * + * All in all, this is a computationally expensive and blocking process, which gets more expensive + * the larger the resolution this Dynamic Texture has, so please be careful how you employ this in your game. + * @param callback The Function to invoke after the snapshot image is created. + * @param type The format of the image to create, usually `image/png` or `image/jpeg`. Default 'image/png'. + * @param encoderOptions The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. Default 0.92. + */ + snapshot(callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback, type?: string, encoderOptions?: number): this; + + /** + * Takes a snapshot of the given pixel from this Dynamic Texture. + * + * The snapshot is taken immediately, but the results are returned via the given callback. + * + * To capture the whole Dynamic Texture see the `snapshot` method. + * To capture a portion of this Dynamic Texture see the `snapshotArea` method. + * + * Unlike the two other snapshot methods, this one will send your callback a `Color` object + * containing the color data for the requested pixel. It doesn't need to create an internal + * Canvas or Image object, so is a lot faster to execute, using less memory than the other snapshot methods. + * @param x The x coordinate of the pixel to get. + * @param y The y coordinate of the pixel to get. + * @param callback The Function to invoke after the snapshot pixel data is extracted. + */ + snapshotPixel(x: number, y: number, callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback): this; + + /** + * Renders this Dynamic Texture onto the Stamp Game Object as a BitmapMask. + * @param renderer A reference to the current active WebGL renderer. + * @param src The Game Object being rendered in this call. + * @param camera The Camera that is rendering the Game Object. + * @param parentMatrix This transform matrix is defined if the game object is nested + */ + renderWebGL(renderer: Phaser.Renderer.WebGL.WebGLRenderer, src: Phaser.GameObjects.Image, camera: Phaser.Cameras.Scene2D.Camera, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * This is a NOOP method. Bitmap Masks are not supported by the Canvas Renderer. + * @param renderer The Canvas Renderer which would be rendered to. + * @param mask The masked Game Object which would be rendered. + * @param camera The Camera to render to. + */ + renderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer, mask: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; + + /** + * Internal destroy handler, called as part of the destroy process. + */ + protected preDestroy(): void; + + } + + 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: string; + + /** + * The Texture Add Key Event. + * + * This event is dispatched by the Texture Manager when a texture with the given key is added to it. + * + * Listen to this event from within a Scene using: `this.textures.on('addtexture-key', listener)`. + */ + const ADD_KEY: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * 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: string; + + /** + * The Texture Remove Key Event. + * + * This event is dispatched by the Texture Manager when a texture with the given key is removed from it. + * + * Listen to this event from within a Scene using: `this.textures.on('removetexture-key', 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_KEY: string; + + } + /** * A Frame is a section of a Texture. */ @@ -92299,6 +94270,31 @@ declare namespace Phaser { } + /** + * Linear filter type. + */ + const LINEAR: number; + + /** + * Nearest Neighbor filter type. + */ + const NEAREST: number; + + namespace Parsers { + /** + * Parses a KTX format Compressed Texture file and generates texture data suitable for WebGL from it. + * @param data The data object created by the Compressed Texture File Loader. + */ + function KTXParser(data: ArrayBuffer): Phaser.Types.Textures.CompressedTextureData; + + /** + * Parses a PVR format Compressed Texture file and generates texture data suitable for WebGL from it. + * @param data The data object created by the Compressed Texture File Loader. + */ + function PVRParser(data: ArrayBuffer): Phaser.Types.Textures.CompressedTextureData; + + } + /** * 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 @@ -92481,12 +94477,16 @@ declare namespace Phaser { } /** - * Textures are managed by the global TextureManager. This is a singleton class that is - * responsible for creating and delivering Textures and their corresponding Frames to Game Objects. + * When Phaser boots it will create an instance of this Texture Manager class. * - * Sprites and other Game Objects get the texture data they need from the TextureManager. + * It is a global manager that handles all textures in your game. You can access it from within + * a Scene via the `this.textures` property. * - * Access it via `scene.textures`. + * Its role is as a manager for all textures that your game uses. It can create, update and remove + * textures globally, as well as parse texture data from external files, such as sprite sheets + * and texture atlases. + * + * Sprites and other texture-based Game Objects get their texture data directly from this class. */ class TextureManager extends Phaser.Events.EventEmitter { /** @@ -92496,21 +94496,43 @@ declare namespace Phaser { constructor(game: Phaser.Game); /** - * The Game that this TextureManager belongs to. + * The Game that the Texture Manager belongs to. + * + * A game will only ever have one instance of a Texture Manager. */ game: Phaser.Game; /** - * The name of this manager. + * The internal name of this manager. */ - name: string; + readonly name: string; /** - * An object that has all of textures that Texture Manager creates. - * Textures are assigned to keys so we can access to any texture that this object has directly by key value without iteration. + * This object contains all Textures that belong to this Texture Manager. + * + * Textures are identified by string-based keys, which are used as the property + * within this object. Therefore, you can access any texture directly from this + * object without any iteration. + * + * You should not typically modify this object directly, but instead use the + * methods provided by the Texture Manager to add and remove entries from it. */ list: object; + /** + * An Image Game Object that belongs to this Texture Manager. + * + * Used as a drawing stamp within Dynamic Textures. + * + * This is not part of the display list and doesn't render. + */ + readonly stamp: Phaser.GameObjects.Image; + + /** + * The crop Rectangle as used by the Stamp when it needs to crop itself. + */ + stampCrop: Phaser.Geom.Rectangle; + /** * Checks the given texture key and throws a console.warn if the key is already in use, then returns false. * @@ -92669,50 +94691,102 @@ declare namespace Phaser { addCanvas(key: string, source: HTMLCanvasElement, skipCache?: boolean): Phaser.Textures.CanvasTexture | null; /** - * Adds a new Texture Atlas to this Texture Manager. - * It can accept either JSON Array or JSON Hash formats, as exported by Texture Packer and similar software. - * @param key The unique string-based key of the Texture. - * @param source The source Image element. - * @param data The Texture Atlas data. - * @param dataSource An optional data Image element. + * Creates a Dynamic Texture instance and adds itself to this Texture Manager. + * + * A Dynamic Texture is a special texture that allows you to draw textures, frames and most kind of + * Game Objects directly to it. + * + * You can take many complex objects and draw them to this one texture, which can then be used as the + * base texture for other Game Objects, such as Sprites. Should you then update this texture, all + * Game Objects using it will instantly be updated as well, reflecting the changes immediately. + * + * It's a powerful way to generate dynamic textures at run-time that are WebGL friendly and don't invoke + * expensive GPU uploads on each change. + * + * See the methods available on the `DynamicTexture` class for more details. + * @param key The string-based key of this Texture. Must be unique within the Texture Manager. + * @param width The width of this Dymamic Texture in pixels. Defaults to 256 x 256. Default 256. + * @param height The height of this Dymamic Texture in pixels. Defaults to 256 x 256. Default 256. */ - addAtlas(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture | null; + addDynamicTexture(key: string, width?: number, height?: number): Phaser.Textures.DynamicTexture | null; /** * Adds a Texture Atlas to this Texture Manager. - * The frame data of the atlas must be stored in an Array within the JSON. - * This is known as a JSON Array in software such as Texture Packer. + * + * In Phaser terminology, a Texture Atlas is a combination of an atlas image and a JSON data file, + * such as those exported by applications like Texture Packer. + * + * It can accept either JSON Array or JSON Hash formats, as exported by Texture Packer and similar software. + * + * As of Phaser 3.60 you can use this method to add a atlas data to an existing Phaser Texture. * @param key The unique string-based key of the Texture. - * @param source The source Image element/s. + * @param source The source Image element/s, or a Phaser Texture. * @param data The Texture Atlas data/s. * @param dataSource An optional data Image element. */ - addAtlasJSONArray(key: string, source: HTMLImageElement | HTMLImageElement[], data: object | object[], dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture | null; + addAtlas(key: string, source: HTMLImageElement | HTMLImageElement[] | Phaser.Textures.Texture, data: object | object[], dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture | null; /** * Adds a Texture Atlas to this Texture Manager. - * The frame data of the atlas must be stored in an Object within the JSON. - * This is known as a JSON Hash in software such as Texture Packer. + * + * In Phaser terminology, a Texture Atlas is a combination of an atlas image and a JSON data file, + * such as those exported by applications like Texture Packer. + * + * The frame data of the atlas must be stored in an Array within the JSON. + * + * This is known as a JSON Array in software such as Texture Packer. + * + * As of Phaser 3.60 you can use this method to add a atlas data to an existing Phaser Texture. * @param key The unique string-based key of the Texture. - * @param source The source Image element. - * @param data The Texture Atlas data. + * @param source The source Image element/s, or a Phaser Texture. + * @param data The Texture Atlas data/s. * @param dataSource An optional data Image element. */ - addAtlasJSONHash(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture | null; + addAtlasJSONArray(key: string, source: HTMLImageElement | HTMLImageElement[] | Phaser.Textures.Texture, data: object | object[], dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture | null; /** - * Adds a Texture Atlas to this Texture Manager, where the atlas data is given - * in the XML format. + * Adds a Texture Atlas to this Texture Manager. + * + * In Phaser terminology, a Texture Atlas is a combination of an atlas image and a JSON data file, + * such as those exported by applications like Texture Packer. + * + * The frame data of the atlas must be stored in an Object within the JSON. + * + * This is known as a JSON Hash in software such as Texture Packer. + * + * As of Phaser 3.60 you can use this method to add a atlas data to an existing Phaser Texture. * @param key The unique string-based key of the Texture. - * @param source The source Image element. + * @param source The source Image element/s, or a Phaser Texture. + * @param data The Texture Atlas data/s. + * @param dataSource An optional data Image element. + */ + addAtlasJSONHash(key: string, source: HTMLImageElement | HTMLImageElement[] | Phaser.Textures.Texture, data: object | object[], dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture | null; + + /** + * Adds a Texture Atlas to this Texture Manager. + * + * In Phaser terminology, a Texture Atlas is a combination of an atlas image and a data file, + * such as those exported by applications like Texture Packer. + * + * The frame data of the atlas must be stored in an XML file. + * + * As of Phaser 3.60 you can use this method to add a atlas data to an existing Phaser Texture. + * @param key The unique string-based key of the Texture. + * @param source The source Image element, or a Phaser Texture. * @param data The Texture Atlas XML data. * @param dataSource An optional data Image element. */ - addAtlasXML(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture | null; + addAtlasXML(key: string, source: HTMLImageElement | Phaser.Textures.Texture, data: object, dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture | null; /** * Adds a Unity Texture Atlas to this Texture Manager. - * The data must be in the form of a Unity YAML file. + * + * In Phaser terminology, a Texture Atlas is a combination of an atlas image and a data file, + * such as those exported by applications like Texture Packer or Unity. + * + * The frame data of the atlas must be stored in a Unity YAML file. + * + * As of Phaser 3.60 you can use this method to add a atlas data to an existing Phaser Texture. * @param key The unique string-based key of the Texture. * @param source The source Image element. * @param data The Texture Atlas data. @@ -92765,12 +94839,14 @@ declare namespace Phaser { * * If the key is `undefined` it will return the `__DEFAULT` Texture. * - * If the key is an instance of a Texture, it will return the key directly. + * If the key is an instance of a Texture, it will return the instance. * - * Finally. if the key is given, but not found and not a Texture instance, it will return the `__MISSING` Texture. - * @param key The unique string-based key of the Texture, or a Texture instance. + * If the key is an instance of a Frame, it will return the frames parent Texture instance. + * + * Finally, if the key is given, but not found, and not a Texture or Frame instance, it will return the `__MISSING` Texture. + * @param key The unique string-based key of the Texture, or a Texture, or Frame instance. */ - get(key: string | Phaser.Textures.Texture): Phaser.Textures.Texture; + get(key: string | Phaser.Textures.Texture | Phaser.Textures.Frame): Phaser.Textures.Texture; /** * Takes a Texture key and Frame name and returns a clone of that Frame if found. @@ -92786,6 +94862,20 @@ declare namespace Phaser { */ getFrame(key: string, frame?: string | number): Phaser.Textures.Frame; + /** + * Parses the 'key' parameter and returns a Texture Frame instance. + * + * It can accept the following formats: + * + * 1) A string + * 2) An array where the elements are: [ key, [frame] ] + * 3) An object with the properties: { key, [frame] } + * 4) A Texture instance - which returns the default frame from the Texture + * 5) A Frame instance - returns itself + * @param key The key to be parsed. + */ + parseFrame(key: string | any[] | object | Phaser.Textures.Texture | Phaser.Textures.Frame): Phaser.Textures.Frame; + /** * Returns an array with all of the keys of all Textures in this Texture Manager. * The output array will exclude the `__DEFAULT`, `__MISSING`, and `__WHITE` keys. @@ -92843,6 +94933,13 @@ declare namespace Phaser { */ each(callback: EachTextureCallback, scope: object, ...args: any[]): void; + /** + * Resets the internal Stamp object, ready for drawing and returns it. + * @param alpha The alpha to use. Default 1. + * @param tint WebGL only. The tint color to use. Default 0xffffff. + */ + resetStamp(alpha?: number, tint?: number): Phaser.GameObjects.Image; + /** * Destroys the Texture Manager and all Textures stored within it. */ @@ -92866,7 +94963,7 @@ declare namespace Phaser { * @param height Optional height of the source image. If not given it's derived from the source itself. * @param flipY Sets the `UNPACK_FLIP_Y_WEBGL` flag the WebGL Texture uses during upload. Default false. */ - constructor(texture: Phaser.Textures.Texture, source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | Phaser.GameObjects.RenderTexture | WebGLTexture, width?: number, height?: number, flipY?: boolean); + constructor(texture: Phaser.Textures.Texture, source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | Phaser.GameObjects.RenderTexture | WebGLTexture | Phaser.Types.Textures.CompressedTextureData | Phaser.Textures.DynamicTexture, width?: number, height?: number, flipY?: boolean); /** * A reference to the Canvas or WebGL Renderer. @@ -92885,7 +94982,7 @@ declare namespace Phaser { * * In Phaser 3.60 and above it can also be a Compressed Texture data object. */ - source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | Phaser.GameObjects.RenderTexture | WebGLTexture | Phaser.Types.Textures.CompressedTextureData; + source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | Phaser.GameObjects.RenderTexture | WebGLTexture | Phaser.Types.Textures.CompressedTextureData | Phaser.Textures.DynamicTexture; /** * The image data. @@ -93007,124 +95104,802 @@ 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 Add Key Event. - * - * This event is dispatched by the Texture Manager when a texture with the given key is added to it. - * - * Listen to this event from within a Scene using: `this.textures.on('addtexture-key', listener)`. - */ - const ADD_KEY: 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; - - /** - * The Texture Remove Key Event. - * - * This event is dispatched by the Texture Manager when a texture with the given key is removed from it. - * - * Listen to this event from within a Scene using: `this.textures.on('removetexture-key', 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_KEY: any; - - } - - /** - * Linear filter type. - */ - const LINEAR: number; - - /** - * Nearest Neighbor filter type. - */ - const NEAREST: number; - - namespace Parsers { - /** - * Parses a KTX format Compressed Texture file and generates texture data suitable for WebGL from it. - * @param data The data object created by the Compressed Texture File Loader. - */ - function KTXParser(data: ArrayBuffer): Phaser.Types.Textures.CompressedTextureData; - - /** - * Parses a PVR format Compressed Texture file and generates texture data suitable for WebGL from it. - * @param data The data object created by the Compressed Texture File Loader. - */ - function PVRParser(data: ArrayBuffer): Phaser.Types.Textures.CompressedTextureData; - - } - } 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 | null; + + /** + * 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 | null; + + /** + * 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 | null; + + /** + * 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 | null; + + /** + * 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 | undefined, 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 | undefined, 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 @@ -93229,6 +96004,324 @@ 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: Phaser.Types.Tilemaps.ObjectLayerConfig[]; + + /** + * 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[]; + + } + /** * The ObjectHelper helps tie objects with `gids` into the tileset * that sits behind them. @@ -93278,6 +96371,195 @@ declare namespace Phaser { } + 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 | null; + + } + + /** + * 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 group The current group layer from the Tiled JSON file. + * @param parentState The state of the parent group (if any). + */ + function CreateGroupLayer(json: object, group?: 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 | null; + + /** + * 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 @@ -95603,6 +98885,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -95617,7 +98900,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string; + blendMode: Phaser.BlendModes | string | number; /** * Sets the Blend Mode being used by this Game Object. @@ -95626,6 +98909,7 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * + * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -95639,9 +98923,9 @@ declare namespace Phaser { * 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. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setBlendMode(value: string | Phaser.BlendModes): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The native (un-scaled) width of this Game Object. @@ -95912,7 +99196,7 @@ declare namespace Phaser { * * 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. + * a Bitmap Mask from any renderable texture-based 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; @@ -96498,1306 +99782,6 @@ 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 | null; - - /** - * 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 | null; - - /** - * 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 | null; - - /** - * 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 | null; - - /** - * 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 | undefined, 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 | undefined, 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: Phaser.Types.Tilemaps.ObjectLayerConfig[]; - - /** - * 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 | null; - - } - - 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 group The current group layer from the Tiled JSON file. - * @param parentState The state of the parent group (if any). - */ - function CreateGroupLayer(json: object, group?: 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 | null; - - /** - * 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. */ @@ -98071,435 +100055,6 @@ declare namespace Phaser { } namespace Tweens { - /** - * The Tween Manager is a default Scene Plugin which controls and updates Tweens. - */ - 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; - - /** - * This toggles the updating state of this Tween Manager. - * - * Setting `paused` to `true` (or calling the `pauseAll` method) will - * stop this Tween Manager from updating any of its tweens, including - * newly created ones. Set back to `false` to resume playback. - */ - paused: boolean; - - /** - * Is this Tween Manager currently processing the tweens as part of - * its 'update' loop? This is set to 'true' at the start of 'update' - * and reset to 'false' at the end of the function. Allows you to trap - * Tween Manager status during tween callbacks. - */ - processing: boolean; - - /** - * An array of Tweens which are actively being processed by the Tween Manager. - */ - tweens: Phaser.Tweens.Tween[]; - - /** - * The time the Tween Manager was updated. - */ - time: number; - - /** - * The time the Tween Manager was started. - */ - startTime: number; - - /** - * The time the Tween Manager should next update. - */ - nextTime: number; - - /** - * The time the Tween Manager previously updated. - */ - prevTime: number; - - /** - * The maximum amount of time, in milliseconds, the browser can - * lag for, before lag smoothing is applied. - * - * See the `TweenManager.setLagSmooth` method for further details. - */ - maxLag: number; - - /** - * The amount of time, in milliseconds, that is used to set the - * delta when lag smoothing is applied. - * - * See the `TweenManager.setLagSmooth` method for further details. - */ - lagSkip: number; - - /** - * An internal value that holds the fps rate. - */ - gap: number; - - /** - * Create a Tween and return it, but does not add it to this Tween Manager. - * - * Please note that a Tween will not manipulate any target property that begins with an underscore. - * - * In order to play this tween, you'll need to add it to a Tween Manager via - * the `TweenManager.existing` method. - * - * You can optionally pass an **array** of Tween Configuration objects to this method and it will create - * one Tween per entry in the array. If an array is given, an array of tweens is returned. - * @param config A Tween Configuration object. Or an array of Tween Configuration objects. - */ - create(config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenBuilderConfig[] | object | object[]): Phaser.Tweens.Tween | Phaser.Tweens.Tween[]; - - /** - * Create a Tween and add it to this Tween Manager by passing a Tween Configuration object. - * - * Example, run from within a Scene: - * - * ```js - * const logo = this.add.image(100, 100, 'logo'); - * - * this.tweens.add({ - * targets: logo, - * x: 600, - * ease: 'Power1', - * duration: 2000 - * }); - * ``` - * - * See the `TweenBuilderConfig` for all of the options you have available. - * - * Playback will start immediately unless the tween has been configured to be paused. - * - * Please note that a Tween will not manipulate any target property that begins with an underscore. - * - * Tweens are designed to be 'fire-and-forget'. They automatically destroy themselves once playback - * is complete, to free-up memory and resources. If you wish to keep a tween after playback, i.e. to - * play it again at a later time, then you should set the `persist` property to `true` in the config. - * However, doing so means it's entirely up to _you_ to destroy the tween when you're finished with it, - * otherwise it will linger in memory forever. - * - * You can optionally pass an **array** of Tween Configuration objects to this method and it will create - * one Tween per entry in the array. If an array is given, an array of tweens is returned. - * - * If you wish to chain Tweens together for sequential playback, see the `TweenManager.chain` method. - * @param config A Tween Configuration object. Or an array of Tween Configuration objects. - */ - add(config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenBuilderConfig[] | object | object[]): Phaser.Tweens.Tween | Phaser.Tweens.Tween[]; - - /** - * Create a sequence of Tweens, chained to one-another, and add them to this Tween Manager. - * - * The tweens are played in order, from start to finish. You can optionally set the chain - * to repeat as many times as you like. Once the chain has finished playing, or repeating if set, - * all tweens in the chain will be destroyed automatically. To override this, set the 'persists' - * argument to 'true'. - * - * Playback will start immediately unless the _first_ Tween has been configured to be paused. - * - * Please note that Tweens will not manipulate any target property that begins with an underscore. - * @param tweens A Tween Chain configuration object, or an array of them to create multiple chains at once. - */ - chain(tweens: Phaser.Types.Tweens.TweenBuilderConfig[] | object[]): Phaser.Tweens.TweenChain | Phaser.Tweens.TweenChain[]; - - /** - * Returns an array containing this Tween and all Tweens chained to it, - * in the order in which they will be played. - * - * If there are no chained Tweens an empty array is returned. - * @param tween The Tween to return the chain from. - */ - getChainedTweens(tween: Phaser.Tweens.Tween): Phaser.Tweens.Tween[]; - - /** - * Check to see if the given Tween instance exists within this Tween Manager. - * - * Will return `true` as long as the Tween is being processed by this Tween Manager. - * - * Will return `false` if not present, or has a state of `REMOVED` or `DESTROYED`. - * @param tween The Tween instance to check. - */ - has(tween: Phaser.Tweens.Tween): boolean; - - /** - * Add an existing Tween to this Tween Manager. - * - * Playback will start immediately unless the tween has been configured to be paused. - * @param tween The Tween to add. - */ - existing(tween: Phaser.Tweens.Tween): this; - - /** - * Create a Number Tween and add it to the active Tween list. - * - * Playback will start immediately unless the tween has been configured to be paused. - * - * Please note that a Tween will not manipulate any target property that begins with an underscore. - * @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; - - /** - * Set the limits that are used when a browser encounters lag, or delays that cause the elapsed - * time between two frames to exceed the expected amount. If this occurs, the Tween Manager will - * act as if the 'skip' amount of times has passed, in order to maintain strict tween sequencing. - * - * This is enabled by default with the values 500ms for the lag limit and 33ms for the skip. - * - * You should not set these to low values, as it won't give time for the browser to ever - * catch-up with itself and reclaim sync. - * - * Call this method with no arguments to disable smoothing. - * - * Call it with the arguments `500` and `33` to reset to the defaults. - * @param limit If the browser exceeds this amount, in milliseconds, it will act as if the 'skip' amount has elapsed instead. Default 0. - * @param skip The amount, in milliseconds, to use as the step delta should the browser lag beyond the 'limit'. Default 0. - */ - setLagSmooth(limit?: number, skip?: number): this; - - /** - * Limits the Tween system to run at a particular frame rate. - * - * You should not set this _above_ the frequency of the browser, - * but instead can use it to throttle the frame rate lower, should - * you need to in certain situations. - * @param fps The frame rate to tick at. Default 240. - */ - setFps(fps?: number): this; - - /** - * Internal method that calculates the delta value, along with the other timing values, - * and returns the new delta. - * - * You should not typically call this method directly. - * @param tick Is this a manual tick, or an automated tick? Default false. - */ - getDelta(tick?: boolean): number; - - /** - * Manually advance the Tween system by one step. - * - * This will update all Tweens even if the Tween Manager is currently - * paused. - */ - tick(): this; - - /** - * Internal update handler. - * - * Calls `TweenManager.step` as long as the Tween Manager has not - * been paused. - */ - update(): void; - - /** - * Updates all Tweens belonging to this Tween Manager. - * - * Called automatically by `update` and `tick`. - * @param tick Is this a manual tick, or an automated tick? Default false. - */ - step(tick?: boolean): void; - - /** - * Removes the given Tween from this Tween Manager, even if it hasn't started - * playback yet. If this method is called while the Tween Manager is processing - * an update loop, then the tween will be flagged for removal at the start of - * the next frame. Otherwise, it is removed immediately. - * - * The removed tween is _not_ destroyed. It is just removed from this Tween Manager. - * @param tween The Tween to be removed. - */ - remove(tween: Phaser.Tweens.Tween): this; - - /** - * Resets the given Tween. - * - * If the Tween does not belong to this Tween Manager, it will first be added. - * - * Then it will seek to position 0 and playback will start on the next frame. - * @param tween The Tween to be reset. - */ - reset(tween: Phaser.Tweens.Tween): this; - - /** - * Checks if a Tween 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): this; - - /** - * 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[]): this; - - /** - * Returns an array containing references to all Tweens in this Tween Manager. - * - * It is safe to mutate the returned array. However, acting upon any of the Tweens - * within it, will adjust those stored in this Tween Manager, as they are passed - * by reference and not cloned. - * - * If you wish to get tweens for a specific target, see `getTweensOf`. - */ - getTweens(): Phaser.Tweens.Tween[]; - - /** - * Returns an array of all Tweens in the Tween Manager which affect the given target, or array of targets. - * - * It's possible for this method to return tweens that are about to be removed from - * the Tween Manager. You should check the state of the returned tween before acting - * upon it. - * @param target The target to look for. Provide an array to look for multiple targets. - */ - getTweensOf(target: object | any[]): Phaser.Tweens.Tween[]; - - /** - * Returns the scale of the time delta for all Tweens owned by this Tween Manager. - */ - getGlobalTimeScale(): number; - - /** - * 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): this; - - /** - * Checks if the given object is being affected by a _playing_ Tween. - * - * If the Tween is paused, this method will return false. - * @param target The object to check if a tween is active for it, or not. - */ - isTweening(target: object): boolean; - - /** - * Destroys all Tweens in this Tween Manager. - * - * The tweens will erase all references to any targets they hold - * and be stopped immediately. - * - * If this method is called while the Tween Manager is running its - * update process, then the tweens will be removed at the start of - * the next frame. Outside of this, they are removed immediately. - */ - killAll(): this; - - /** - * Stops all Tweens which affect the given target or array of targets. - * - * The tweens will erase all references to any targets they hold - * and be stopped immediately. - * - * If this method is called while the Tween Manager is running its - * update process, then the tweens will be removed at the start of - * the next frame. Outside of this, they are removed immediately. - * @param target The target to kill the tweens of. Provide an array to use multiple targets. - */ - killTweensOf(target: object | any[]): this; - - /** - * Pauses this Tween Manager. No Tweens will update while paused. - * - * This includes tweens created after this method was called. - * - * See `TweenManager#resumeAll` to resume the playback. - * - * As of Phaser 3.60 you can also toggle the boolean property `TweenManager.paused`. - */ - pauseAll(): this; - - /** - * Resumes playback of this Tween Manager. - * - * All active Tweens will continue updating. - * - * See `TweenManager#pauseAll` to pause the playback. - * - * As of Phaser 3.60 you can also toggle the boolean property `TweenManager.paused`. - */ - resumeAll(): this; - - /** - * 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. @@ -98664,7 +100219,7 @@ declare namespace Phaser { * Note that this event is usually dispatched already by the time you call `this.tweens.add()`, and is * meant for use with `tweens.create()` and/or `tweens.existing()`. */ - const TWEEN_ACTIVE: any; + const TWEEN_ACTIVE: string; /** * The Tween Complete Event. @@ -98688,7 +100243,7 @@ declare namespace Phaser { * tween.on('complete', listener); * ``` */ - const TWEEN_COMPLETE: any; + const TWEEN_COMPLETE: string; /** * The Tween Loop Event. @@ -98715,7 +100270,7 @@ declare namespace Phaser { * tween.on('loop', listener); * ``` */ - const TWEEN_LOOP: any; + const TWEEN_LOOP: string; /** * The Tween Pause Event. @@ -98736,7 +100291,7 @@ declare namespace Phaser { * tween.pause(); * ``` */ - const TWEEN_PAUSE: any; + const TWEEN_PAUSE: string; /** * The Tween Repeat Event. @@ -98763,7 +100318,7 @@ declare namespace Phaser { * tween.on('repeat', listener); * ``` */ - const TWEEN_REPEAT: any; + const TWEEN_REPEAT: string; /** * The Tween Resume Event. @@ -98784,7 +100339,7 @@ declare namespace Phaser { * tween.resume(); * ``` */ - const TWEEN_RESUME: any; + const TWEEN_RESUME: string; /** * The Tween Start Event. @@ -98807,7 +100362,7 @@ declare namespace Phaser { * tween.on('start', listener); * ``` */ - const TWEEN_START: any; + const TWEEN_START: string; /** * The Tween Stop Event. @@ -98826,7 +100381,7 @@ declare namespace Phaser { * tween.on('stop', listener); * ``` */ - const TWEEN_STOP: any; + const TWEEN_STOP: string; /** * The Tween Update Event. @@ -98849,7 +100404,7 @@ declare namespace Phaser { * tween.on('update', listener); * ``` */ - const TWEEN_UPDATE: any; + const TWEEN_UPDATE: string; /** * The Tween Yoyo Event. @@ -98877,7 +100432,7 @@ declare namespace Phaser { * tween.on('yoyo', listener); * ``` */ - const TWEEN_YOYO: any; + const TWEEN_YOYO: string; } @@ -99512,6 +101067,88 @@ declare namespace Phaser { } + /** + * Phaser Tween States. + */ + enum States { + /** + * TweenData state. + */ + CREATED, + /** + * TweenData state. + */ + DELAY, + /** + * TweenData state. + */ + PENDING_RENDER, + /** + * TweenData state. + */ + PLAYING_FORWARD, + /** + * TweenData state. + */ + PLAYING_BACKWARD, + /** + * TweenData state. + */ + HOLD_DELAY, + /** + * TweenData state. + */ + REPEAT_DELAY, + /** + * TweenData state. + */ + COMPLETE, + /** + * Tween state. The Tween has been created but has not yet been added to the Tween Manager. + */ + PENDING, + /** + * Tween state. The Tween is active within the Tween Manager. This means it is either playing, + * or was playing and is currently paused, but in both cases it's still being processed by + * the Tween Manager, so is considered 'active'. + */ + ACTIVE, + /** + * Tween state. The Tween is waiting for a loop countdown to elapse. + */ + LOOP_DELAY, + /** + * Tween state. The Tween is waiting for a complete delay to elapse. + */ + COMPLETE_DELAY, + /** + * Tween state. The Tween is waiting for a starting delay to elapse. + */ + START_DELAY, + /** + * Tween state. The Tween has finished playback and is waiting to be removed from the Tween Manager. + */ + PENDING_REMOVE, + /** + * Tween state. The Tween has been removed from the Tween Manager. + */ + REMOVED, + /** + * Tween state. The Tween has finished playback but was flagged as 'persistent' during creation, + * so will not be automatically removed by the Tween Manager. + */ + FINISHED, + /** + * Tween state. The Tween has been destroyed and can no longer be played by a Tween Manager. + */ + DESTROYED, + } + + /** + * Phaser Tween state constants. + */ + type StateType = Phaser.Tweens.States; + /** * 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 @@ -100136,98 +101773,437 @@ declare namespace Phaser { } /** - * Phaser Tween States. + * The Tween Manager is a default Scene Plugin which controls and updates Tweens. */ - enum States { + class TweenManager { /** - * TweenData state. + * + * @param scene The Scene which owns this Tween Manager. */ - CREATED, - /** - * TweenData state. - */ - DELAY, - /** - * TweenData state. - */ - PENDING_RENDER, - /** - * TweenData state. - */ - PLAYING_FORWARD, - /** - * TweenData state. - */ - PLAYING_BACKWARD, - /** - * TweenData state. - */ - HOLD_DELAY, - /** - * TweenData state. - */ - REPEAT_DELAY, - /** - * TweenData state. - */ - COMPLETE, - /** - * Tween state. The Tween has been created but has not yet been added to the Tween Manager. - */ - PENDING, - /** - * Tween state. The Tween is active within the Tween Manager. This means it is either playing, - * or was playing and is currently paused, but in both cases it's still being processed by - * the Tween Manager, so is considered 'active'. - */ - ACTIVE, - /** - * Tween state. The Tween is waiting for a loop countdown to elapse. - */ - LOOP_DELAY, - /** - * Tween state. The Tween is waiting for a complete delay to elapse. - */ - COMPLETE_DELAY, - /** - * Tween state. The Tween is waiting for a starting delay to elapse. - */ - START_DELAY, - /** - * Tween state. The Tween has finished playback and is waiting to be removed from the Tween Manager. - */ - PENDING_REMOVE, - /** - * Tween state. The Tween has been removed from the Tween Manager. - */ - REMOVED, - /** - * Tween state. The Tween has finished playback but was flagged as 'persistent' during creation, - * so will not be automatically removed by the Tween Manager. - */ - FINISHED, - /** - * Tween state. The Tween has been destroyed and can no longer be played by a Tween Manager. - */ - DESTROYED, - } + constructor(scene: Phaser.Scene); - /** - * Phaser Tween state constants. - */ - type StateType = Phaser.Tweens.States; + /** + * 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; + + /** + * This toggles the updating state of this Tween Manager. + * + * Setting `paused` to `true` (or calling the `pauseAll` method) will + * stop this Tween Manager from updating any of its tweens, including + * newly created ones. Set back to `false` to resume playback. + */ + paused: boolean; + + /** + * Is this Tween Manager currently processing the tweens as part of + * its 'update' loop? This is set to 'true' at the start of 'update' + * and reset to 'false' at the end of the function. Allows you to trap + * Tween Manager status during tween callbacks. + */ + processing: boolean; + + /** + * An array of Tweens which are actively being processed by the Tween Manager. + */ + tweens: Phaser.Tweens.Tween[]; + + /** + * The time the Tween Manager was updated. + */ + time: number; + + /** + * The time the Tween Manager was started. + */ + startTime: number; + + /** + * The time the Tween Manager should next update. + */ + nextTime: number; + + /** + * The time the Tween Manager previously updated. + */ + prevTime: number; + + /** + * The maximum amount of time, in milliseconds, the browser can + * lag for, before lag smoothing is applied. + * + * See the `TweenManager.setLagSmooth` method for further details. + */ + maxLag: number; + + /** + * The amount of time, in milliseconds, that is used to set the + * delta when lag smoothing is applied. + * + * See the `TweenManager.setLagSmooth` method for further details. + */ + lagSkip: number; + + /** + * An internal value that holds the fps rate. + */ + gap: number; + + /** + * Create a Tween and return it, but does not add it to this Tween Manager. + * + * Please note that a Tween will not manipulate any target property that begins with an underscore. + * + * In order to play this tween, you'll need to add it to a Tween Manager via + * the `TweenManager.existing` method. + * + * You can optionally pass an **array** of Tween Configuration objects to this method and it will create + * one Tween per entry in the array. If an array is given, an array of tweens is returned. + * @param config A Tween Configuration object. Or an array of Tween Configuration objects. + */ + create(config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenBuilderConfig[] | object | object[]): Phaser.Tweens.Tween | Phaser.Tweens.Tween[]; + + /** + * Create a Tween and add it to this Tween Manager by passing a Tween Configuration object. + * + * Example, run from within a Scene: + * + * ```js + * const logo = this.add.image(100, 100, 'logo'); + * + * this.tweens.add({ + * targets: logo, + * x: 600, + * ease: 'Power1', + * duration: 2000 + * }); + * ``` + * + * See the `TweenBuilderConfig` for all of the options you have available. + * + * Playback will start immediately unless the tween has been configured to be paused. + * + * Please note that a Tween will not manipulate any target property that begins with an underscore. + * + * Tweens are designed to be 'fire-and-forget'. They automatically destroy themselves once playback + * is complete, to free-up memory and resources. If you wish to keep a tween after playback, i.e. to + * play it again at a later time, then you should set the `persist` property to `true` in the config. + * However, doing so means it's entirely up to _you_ to destroy the tween when you're finished with it, + * otherwise it will linger in memory forever. + * + * You can optionally pass an **array** of Tween Configuration objects to this method and it will create + * one Tween per entry in the array. If an array is given, an array of tweens is returned. + * + * If you wish to chain Tweens together for sequential playback, see the `TweenManager.chain` method. + * @param config A Tween Configuration object. Or an array of Tween Configuration objects. + */ + add(config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenBuilderConfig[] | object | object[]): Phaser.Tweens.Tween | Phaser.Tweens.Tween[]; + + /** + * Create a sequence of Tweens, chained to one-another, and add them to this Tween Manager. + * + * The tweens are played in order, from start to finish. You can optionally set the chain + * to repeat as many times as you like. Once the chain has finished playing, or repeating if set, + * all tweens in the chain will be destroyed automatically. To override this, set the 'persists' + * argument to 'true'. + * + * Playback will start immediately unless the _first_ Tween has been configured to be paused. + * + * Please note that Tweens will not manipulate any target property that begins with an underscore. + * @param tweens A Tween Chain configuration object, or an array of them to create multiple chains at once. + */ + chain(tweens: Phaser.Types.Tweens.TweenChainBuilderConfig | Phaser.Types.Tweens.TweenChainBuilderConfig[] | object | object[]): Phaser.Tweens.TweenChain | Phaser.Tweens.TweenChain[]; + + /** + * Returns an array containing this Tween and all Tweens chained to it, + * in the order in which they will be played. + * + * If there are no chained Tweens an empty array is returned. + * @param tween The Tween to return the chain from. + */ + getChainedTweens(tween: Phaser.Tweens.Tween): Phaser.Tweens.Tween[]; + + /** + * Check to see if the given Tween instance exists within this Tween Manager. + * + * Will return `true` as long as the Tween is being processed by this Tween Manager. + * + * Will return `false` if not present, or has a state of `REMOVED` or `DESTROYED`. + * @param tween The Tween instance to check. + */ + has(tween: Phaser.Tweens.Tween): boolean; + + /** + * Add an existing Tween to this Tween Manager. + * + * Playback will start immediately unless the tween has been configured to be paused. + * @param tween The Tween to add. + */ + existing(tween: Phaser.Tweens.Tween): this; + + /** + * Create a Number Tween and add it to the active Tween list. + * + * Playback will start immediately unless the tween has been configured to be paused. + * + * Please note that a Tween will not manipulate any target property that begins with an underscore. + * @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; + + /** + * Set the limits that are used when a browser encounters lag, or delays that cause the elapsed + * time between two frames to exceed the expected amount. If this occurs, the Tween Manager will + * act as if the 'skip' amount of times has passed, in order to maintain strict tween sequencing. + * + * This is enabled by default with the values 500ms for the lag limit and 33ms for the skip. + * + * You should not set these to low values, as it won't give time for the browser to ever + * catch-up with itself and reclaim sync. + * + * Call this method with no arguments to disable smoothing. + * + * Call it with the arguments `500` and `33` to reset to the defaults. + * @param limit If the browser exceeds this amount, in milliseconds, it will act as if the 'skip' amount has elapsed instead. Default 0. + * @param skip The amount, in milliseconds, to use as the step delta should the browser lag beyond the 'limit'. Default 0. + */ + setLagSmooth(limit?: number, skip?: number): this; + + /** + * Limits the Tween system to run at a particular frame rate. + * + * You should not set this _above_ the frequency of the browser, + * but instead can use it to throttle the frame rate lower, should + * you need to in certain situations. + * @param fps The frame rate to tick at. Default 240. + */ + setFps(fps?: number): this; + + /** + * Internal method that calculates the delta value, along with the other timing values, + * and returns the new delta. + * + * You should not typically call this method directly. + * @param tick Is this a manual tick, or an automated tick? Default false. + */ + getDelta(tick?: boolean): number; + + /** + * Manually advance the Tween system by one step. + * + * This will update all Tweens even if the Tween Manager is currently + * paused. + */ + tick(): this; + + /** + * Internal update handler. + * + * Calls `TweenManager.step` as long as the Tween Manager has not + * been paused. + */ + update(): void; + + /** + * Updates all Tweens belonging to this Tween Manager. + * + * Called automatically by `update` and `tick`. + * @param tick Is this a manual tick, or an automated tick? Default false. + */ + step(tick?: boolean): void; + + /** + * Removes the given Tween from this Tween Manager, even if it hasn't started + * playback yet. If this method is called while the Tween Manager is processing + * an update loop, then the tween will be flagged for removal at the start of + * the next frame. Otherwise, it is removed immediately. + * + * The removed tween is _not_ destroyed. It is just removed from this Tween Manager. + * @param tween The Tween to be removed. + */ + remove(tween: Phaser.Tweens.Tween): this; + + /** + * Resets the given Tween. + * + * If the Tween does not belong to this Tween Manager, it will first be added. + * + * Then it will seek to position 0 and playback will start on the next frame. + * @param tween The Tween to be reset. + */ + reset(tween: Phaser.Tweens.Tween): this; + + /** + * Checks if a Tween 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): this; + + /** + * 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[]): this; + + /** + * Returns an array containing references to all Tweens in this Tween Manager. + * + * It is safe to mutate the returned array. However, acting upon any of the Tweens + * within it, will adjust those stored in this Tween Manager, as they are passed + * by reference and not cloned. + * + * If you wish to get tweens for a specific target, see `getTweensOf`. + */ + getTweens(): Phaser.Tweens.Tween[]; + + /** + * Returns an array of all Tweens in the Tween Manager which affect the given target, or array of targets. + * + * It's possible for this method to return tweens that are about to be removed from + * the Tween Manager. You should check the state of the returned tween before acting + * upon it. + * @param target The target to look for. Provide an array to look for multiple targets. + */ + getTweensOf(target: object | any[]): Phaser.Tweens.Tween[]; + + /** + * Returns the scale of the time delta for all Tweens owned by this Tween Manager. + */ + getGlobalTimeScale(): number; + + /** + * 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): this; + + /** + * Checks if the given object is being affected by a _playing_ Tween. + * + * If the Tween is paused, this method will return false. + * @param target The object to check if a tween is active for it, or not. + */ + isTweening(target: object): boolean; + + /** + * Destroys all Tweens in this Tween Manager. + * + * The tweens will erase all references to any targets they hold + * and be stopped immediately. + * + * If this method is called while the Tween Manager is running its + * update process, then the tweens will be removed at the start of + * the next frame. Outside of this, they are removed immediately. + */ + killAll(): this; + + /** + * Stops all Tweens which affect the given target or array of targets. + * + * The tweens will erase all references to any targets they hold + * and be stopped immediately. + * + * If this method is called while the Tween Manager is running its + * update process, then the tweens will be removed at the start of + * the next frame. Outside of this, they are removed immediately. + * @param target The target to kill the tweens of. Provide an array to use multiple targets. + */ + killTweensOf(target: object | any[]): this; + + /** + * Pauses this Tween Manager. No Tweens will update while paused. + * + * This includes tweens created after this method was called. + * + * See `TweenManager#resumeAll` to resume the playback. + * + * As of Phaser 3.60 you can also toggle the boolean property `TweenManager.paused`. + */ + pauseAll(): this; + + /** + * Resumes playback of this Tween Manager. + * + * All active Tweens will continue updating. + * + * See `TweenManager#pauseAll` to pause the playback. + * + * As of Phaser 3.60 you can also toggle the boolean property `TweenManager.paused`. + */ + resumeAll(): this; + + /** + * 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 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. @@ -100369,6 +102345,220 @@ 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. 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 above another one in the array. * The array is modified in-place. @@ -100654,220 +102844,6 @@ 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. 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 { @@ -100890,6 +102866,14 @@ 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. @@ -101128,6 +103112,12 @@ 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. * @@ -101136,12 +103126,6 @@ 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; - } } @@ -102049,14 +104033,14 @@ declare type EachSetCallback = (entry: E, index: number)=>boolean | null; declare type EachTextureCallback = (texture: Phaser.Textures.Texture, ...args: any[])=>void; -declare type TilemapFilterCallback = (value: Phaser.GameObjects.GameObject, index: number, array: Phaser.GameObjects.GameObject[])=>Phaser.GameObjects.GameObject; - -declare type TilemapFindCallback = (value: Phaser.GameObjects.GameObject, index: number, array: Phaser.GameObjects.GameObject[])=>boolean; - declare type FindTileCallback = (value: Phaser.Tilemaps.Tile, index: number, array: Phaser.Tilemaps.Tile[])=>boolean; 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[])=>Phaser.GameObjects.GameObject; + +declare type TilemapFindCallback = (value: Phaser.GameObjects.GameObject, index: number, array: Phaser.GameObjects.GameObject[])=>boolean; + /** * Phaser.Class */ From f3f3e64471a6a74f290146ce314daabea13bcbf4 Mon Sep 17 00:00:00 2001 From: Yuval Greenfield Date: Mon, 10 Oct 2022 10:05:33 -0700 Subject: [PATCH 3/4] Revert generated files to merge PR --- scripts/tsgen/bin/Parser.js | 2 +- scripts/tsgen/bin/Parser.js.map | 2 +- types/phaser.d.ts | 29338 ++++++++++++++---------------- 3 files changed, 13678 insertions(+), 15664 deletions(-) diff --git a/scripts/tsgen/bin/Parser.js b/scripts/tsgen/bin/Parser.js index 1a24de374..81bc26cf1 100644 --- a/scripts/tsgen/bin/Parser.js +++ b/scripts/tsgen/bin/Parser.js @@ -25,7 +25,7 @@ class Parser { } emit() { let ignored = []; - let result = '// DO NOT EDIT THIS FILE! It was generated by running `npm run tsgen`\n/// \n\n'; + let result = '/// \n\n'; result = result.concat(this.topLevel.reduce((out, obj) => { return out + dom.emit(obj); }, '')); diff --git a/scripts/tsgen/bin/Parser.js.map b/scripts/tsgen/bin/Parser.js.map index 6978dffbe..87c81a457 100644 --- a/scripts/tsgen/bin/Parser.js.map +++ b/scripts/tsgen/bin/Parser.js.map @@ -1 +1 @@ -{"version":3,"file":"Parser.js","sourceRoot":"","sources":["../src/Parser.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAE/B,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAEzC,MAAa,MAAM;IAMf,YAAY,IAAW;QAEnB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QAErB,qDAAqD;QACrD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAExB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAE1B,yCAAyC;QACzC,yIAAyI;QACzI,kDAAkD;QAClD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAE9B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAE1B,oBAAoB;QACpB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAEjE,qBAAqB;QACrB,MAAM,kBAAkB,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAEvD,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;QAEnE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI;QAEA,IAAI,OAAO,GAAG,EAAE,CAAC;QAEjB,IAAI,MAAM,GAAG,+GAA+G,CAAC;QAE7H,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,GAA4B,EAAE,EAAE;YACtF,OAAO,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAER,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EACtB;YACI,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;YAC7C,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;SACxB;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAEO,YAAY,CAAC,IAAW;QAE5B,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;QAClF,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;QAElF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAElC,IAAI,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAErB,QAAQ,MAAM,CAAC,QAAQ,EACvB;gBACI,KAAK,qCAAqC,CAAC;gBAC3C,KAAK,2CAA2C,CAAC;gBACjD,KAAK,yCAAyC,CAAC;gBAC/C,KAAK,yCAAyC,CAAC;gBAC/C,KAAK,4CAA4C,CAAC;gBAClD,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,qCAAqC,CAAC;gBAC3C,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,kCAAkC,CAAC;gBACxC,KAAK,yCAAyC,CAAC;gBAC/C,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,sCAAsC,CAAC;gBAC5C,KAAK,4CAA4C,CAAC;gBAClD,KAAK,wCAAwC,CAAC;gBAC9C,KAAK,4CAA4C,CAAC;gBAClD,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,uCAAuC,CAAC;gBAC7C,KAAK,2CAA2C,CAAC;gBACjD,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,sCAAsC,CAAC;gBAC5C,KAAK,yCAAyC,CAAC;gBAC/C,KAAK,uCAAuC;oBACxC,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC;oBACtB,MAAM;gBAEV,+BAA+B;gBAC/B,KAAK,mBAAmB,CAAC;gBACzB,KAAK,mBAAmB,CAAC;gBACzB,KAAK,4BAA4B,CAAC;gBAClC,KAAK,gCAAgC,CAAC;gBACtC,KAAK,qBAAqB,CAAC;gBAC3B,KAAK,0BAA0B,CAAC;gBAChC,KAAK,yBAAyB,CAAC;gBAC/B,KAAK,mBAAmB,CAAC;gBACzB,KAAK,4BAA4B,CAAC;gBAClC,KAAK,6BAA6B,CAAC;gBACnC,KAAK,sBAAsB;oBACvB,sDAAsD;oBACtD,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC;oBACvB,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC;oBACrB,MAAM;aACb;YAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,mCAAmC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,mCAAmC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,mCAAmC,CAAC,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EACvP;gBACI,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC;aACzB;YAED,kEAAkE;YAElE,IAAI,GAAwB,CAAC;YAC7B,IAAI,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC;YAE7B,QAAQ,MAAM,CAAC,IAAI,EAAE;gBACjB,KAAK,WAAW;oBACZ,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;oBACnC,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC;oBAC5B,MAAM;gBACV,KAAK,OAAO;oBACR,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;oBAC/B,MAAM;gBACV,KAAK,OAAO;oBACR,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;oBACnC,MAAM;gBACV,KAAK,QAAQ;oBACT,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,EAAE;wBACxB,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;wBAC9B,MAAM;qBACT;gBACL,KAAK,UAAU;oBACX,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;oBAChC,MAAM;gBACV,KAAK,UAAU;oBACX,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;oBAClC,MAAM;gBACV,KAAK,SAAS;oBACV,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;oBACjC,MAAM;gBACV,KAAK,OAAO;oBACR,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;oBAC/B,MAAM;gBACV;oBACI,OAAO,CAAC,GAAG,CAAC,uBAAuB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;oBACnD,MAAM;aACb;YAED,IAAI,GAAG,EACP;gBACI,IAAI,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAC9B;oBACI,OAAO,CAAC,GAAG,CAAC,wCAAwC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;oBACxE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;oBACpB,SAAS;iBACZ;gBAED,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC;gBAEjC,IAAI,MAAM,CAAC,WAAW,EACtB;oBACI,IAAI,SAAS,GAAG,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;oBACvC,GAAG,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;iBACnF;aACJ;SACJ;IACL,CAAC;IAEO,cAAc,CAAC,IAAW;QAE9B,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;QAClF,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/B,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;QAElF,IAAI,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;QAEjC,KAAK,IAAI,MAAM,IAAI,IAAI,EACvB;YACI,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAE3G,IAAI,CAAC,GAAG,EACR;gBACI,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,YAAY,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;gBACzD,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;gBAE3C,SAAS;aACZ;YAED,IAAI,CAAC,MAAM,CAAC,QAAQ,EACpB;gBACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAA8B,CAAC,CAAC;aACtD;iBAED;gBACI,IAAI,iBAAiB,GAAG,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,IAAI,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC;gBAE5H,IAAI,MAAM,GAAG,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAExI,IAAI,CAAC,MAAM,EACX;oBACI,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,YAAY,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;oBACzD,OAAO,CAAC,GAAG,CAAC,mBAAmB,MAAM,CAAC,QAAQ,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,gBAAgB,MAAM,CAAC,QAAQ,wBAAwB,CAAC,CAAC;iBAC3J;gBAED,IAAU,MAAO,CAAC,OAAO,EACzB;oBACU,MAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;iBACnC;qBAED;oBACI,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,YAAY,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;oBACzD,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;oBAC5C,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;iBACvB;gBAEK,GAAI,CAAC,OAAO,GAAG,MAAM,CAAC;gBAE5B,wDAAwD;gBACxD,IAAI,CAAE,MAAc,CAAC,IAAI,KAAK,OAAO,IAAK,MAAc,CAAC,IAAI,KAAK,WAAW,CAAC,IAAK,GAAW,CAAC,IAAI,KAAK,UAAU,EAClH;oBACK,GAAW,CAAC,IAAI,GAAG,QAAQ,CAAC;iBAChC;gBAED,uDAAuD;gBACvD,IAAK,MAAc,CAAC,IAAI,KAAK,WAAW,IAAK,GAAW,CAAC,IAAI,KAAK,UAAU,EAC5E;oBACI,IAAI,MAAM,CAAC,IAAI,IAAI,UAAU,EAC7B;wBACK,GAAW,CAAC,IAAI,GAAG,OAAO,CAAC;qBAC/B;yBAED;wBACK,GAAW,CAAC,IAAI,GAAG,KAAK,CAAC;qBAC7B;iBACJ;aACJ;SACJ;IACL,CAAC;IAEO,kBAAkB,CAAC,IAAW;QAElC,KAAK,IAAI,MAAM,IAAI,IAAI,EACvB;YACI,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAEzG,IAAI,CAAC,GAAG,EACR;gBACI,OAAO,CAAC,GAAG,CAAC,oBAAoB,MAAM,CAAC,QAAQ,MAAM,CAAC,CAAC;gBACvD,SAAS;aACZ;YAED,IAAI,CAAO,GAAI,CAAC,OAAO;gBAAE,SAAS;YAElC,IAAI,MAAM,CAAC,SAAS,EACpB;gBACI,4DAA4D;gBAC5D,IAAI,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAEzC,IAAI,CAAC,IAAI,IAAI,CAAO,IAAK,CAAC,OAAO,EACjC;oBACI,MAAM,IAAI,MAAM,CAAC,QAAQ,0BAA0B,MAAM,CAAC,QAAQ,0BAA0B,CAAC;iBAChG;gBAED,IAAU,IAAK,CAAC,OAAO,CAAC,IAAI,IAAI,WAAW,EAC3C;oBACU,GAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAO,GAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;oBACxE,GAAI,CAAC,OAAO,GAAG,IAAI,CAAC;iBAC7B;aACJ;SACJ;IACL,CAAC;IAEO,cAAc,CAAC,IAAW;QAC9B,KAAK,IAAI,MAAM,IAAI,IAAI,EAAE;YACrB,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACxC,IAAI,CAAC,GAAG,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO;gBAAE,SAAS;YAE9C,IAAI,CAAC,GAAG,GAA2B,CAAC;YAEpC,mBAAmB;YACnB,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;gBAC3C,KAAK,IAAI,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE;oBACjC,IAAI,IAAI,GAAW,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;oBAEjD,IAAI,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA,2EAA2E;oBAEtH,IAAI,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAoD,CAAC;oBAE7F,IAAI,CAAC,QAAQ,EAAE;wBACX,OAAO,CAAC,GAAG,CAAC,kCAAkC,OAAO,QAAQ,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;qBACnF;yBAAM;wBACH,IAAI,QAAQ,CAAC,IAAI,IAAI,OAAO,EAAE;4BAC1B,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;yBACvC;6BAAM;4BACH,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;yBACjD;qBACJ;iBACJ;aACJ;SACJ;IACL,CAAC;IAEO,eAAe,CAAC,MAAW;QAE/B;;;;;;;;;;;;;;;WAeG;QAEC,8CAA8C;QAElD,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAE5C,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,WAAW,CAAC,MAAW;QAC3B,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAExC,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,IAAI,MAAM,CAAC,MAAM,EAAE;YACf,IAAI,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACxC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC7B,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;YAEzB,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,IAAK,CAAC,OAAO,GAAG,GAAG,CAAC;SAC7B;QAED,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAEzC,IAAI,MAAM,CAAC,SAAS;YAChB,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,+BAA+B;QAExG,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,eAAe,CAAC,MAAW;QAC/B,OAAO,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAEO,YAAY,CAAC,MAAW;QAC5B,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAElC,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEjD,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAEvC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,WAAW,CAAC,MAAW;QAE3B,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAElC,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAE9C,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,UAAU,CAAC,MAAW;QAC1B,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAE9C,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,cAAc,CAAC,MAAW;QAC9B,IAAI,UAAU,GAAa,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;QAEzC,IAAI,MAAM,CAAC,OAAO,EAAE;YAChB,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;SAClD;QAED,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;QAC7D,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE5B,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;QAEjD,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,aAAa,CAAC,MAAW;QAC7B,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACtC,IAAI,IAAI,GAAG,IAAI,CAAC;QAEhB,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;YACnC,IAAI,UAAU,GAAG,EAAE,CAAC;YAEpB,KAAK,IAAI,OAAO,IAAI,MAAM,CAAC,UAAU,EAAE;gBACnC,IAAI,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;gBACtC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACtB,IAAI,OAAO,CAAC,WAAW;oBACnB,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;aAC7E;YAED,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YAEzC,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;gBAC3C,IAAI,iBAAiB,GAAG,EAAE,CAAC;gBAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBAC7C,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBAC7E;gBACD,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC7B,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;aACrD;SAEJ;aAAM;YACH,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE;gBACpC,IAAI,UAAU,GAAa,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;gBACzC,IAAI,MAAM,CAAC,OAAO,EAAE;oBAChB,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;iBAClD;gBACD,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;gBACjD,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;aAChC;iBAAM;gBACH,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;aACjC;SACJ;QAED,IAAI,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEhD,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QAEzC,OAAO,KAAK,CAAC;IACjB,CAAC;IAEO,SAAS,CAAC,MAAW,EAAE,GAAyD;QACpF,IAAI,UAAU,GAAoB,EAAE,CAAC;QAErC,IAAI,MAAM,CAAC,IAAI,EAAE;YACb,IAAI,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACjD,IAAI,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;YACzE,IAAI,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAEtD,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC1B;QAED,IAAI,MAAM,CAAC,MAAM,EAAE;YAEf,IAAI,QAAQ,GAAG,KAAK,CAAC;YAErB,GAAG,CAAC,YAAY,GAAG,EAAE,CAAC;YAEtB,KAAK,IAAI,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE;gBAEhC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAClB;oBACI,OAAO,CAAC,GAAG,CAAC,kBAAkB,MAAM,CAAC,QAAQ,QAAQ,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;oBAEnG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;iBAC1B;gBAED,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE;oBAElC,OAAO,CAAC,GAAG,CAAC,yCAAyC,MAAM,CAAC,QAAQ,QAAQ,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;oBAE1H,IAAI,UAAU,GAAG,QAAQ,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;oBAEzG,IAAI,QAAQ,CAAC,WAAW;wBACpB,GAAG,CAAC,YAAY,IAAI,YAAY,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,GAAG,UAAU,CAAC;yBAClH,IAAI,UAAU,CAAC,MAAM;wBACtB,GAAG,CAAC,YAAY,IAAI,YAAY,QAAQ,CAAC,IAAI,GAAG,GAAG,UAAU,CAAC;oBAClE,SAAS;iBACZ;gBAED,IAAI,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC9F,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAEvB,IAAI,QAAQ,IAAI,QAAQ,CAAC,QAAQ,IAAI,IAAI,EAAE;oBACvC,OAAO,CAAC,GAAG,CAAC,+CAA+C,QAAQ,CAAC,IAAI,UAAU,MAAM,CAAC,QAAQ,QAAQ,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;oBACvJ,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC;iBAC5B;gBAED,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;gBAEnC,QAAQ,GAAG,QAAQ,IAAI,QAAQ,CAAC,QAAQ,KAAK,IAAI,CAAC;gBAElD,IAAI,UAAU,GAAG,QAAQ,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBAEzG,IAAI,QAAQ,CAAC,WAAW;oBACpB,GAAG,CAAC,YAAY,IAAI,YAAY,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,GAAG,UAAU,CAAC;qBAClH,IAAI,UAAU,CAAC,MAAM;oBACtB,GAAG,CAAC,YAAY,IAAI,YAAY,QAAQ,CAAC,IAAI,GAAG,GAAG,UAAU,CAAC;aACrE;SACJ;QAED,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC;IAChC,CAAC;IAEO,SAAS,CAAC,OAAY,EAAE,YAAY,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI;QACxD,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;YAC3B,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;SACvB;aAAM;YACH,IAAI,KAAK,GAAG,EAAE,CAAC;YACf,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE;gBAEjC,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;gBAElC,IAAI,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;gBAErE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACpB;YACD,IAAI,OAAO,CAAC,QAAQ,EAAE;gBAClB,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;aAC5B;YACD,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC;gBAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;;gBAClC,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACvC;IACL,CAAC;IAEO,eAAe,CAAC,IAAY;QAChC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE;YACzB,IAAI,GAAY,IAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAChD;QACD,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,KAAK,oBAAoB,EAAE;YAC3D,IAAI,GAAY,IAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAC/C;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,eAAe,CAAC,IAAY;QAChC,IAAI,IAAI,KAAK,OAAO;YAAE,OAAO,QAAQ,CAAC;QACtC,IAAI,IAAI,KAAK,UAAU;YAAE,OAAO,UAAU,CAAC;QAC3C,IAAI,IAAI,KAAK,oBAAoB;YAAE,OAAO,YAAY,CAAC;QACvD,IAAI,IAAI,KAAK,OAAO;YAAE,OAAO,OAAO,CAAC;QAErC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;YAC3B,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;YAE1C,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;gBACvB,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;aAClD;SACJ;aAAM,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YACnC,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YAE3C,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;gBACvB,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE;oBAC/B,IAAI,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBAClC,OAAO,UAAU,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;iBAC1F;qBAAM;oBACH,OAAO,mBAAmB,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;iBACjE;aACJ;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,YAAY,CAAC,MAAW,EAAE,GAAwC;QACtE,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC;QACtC,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,EAAE;YAC1B,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC;YACrC,IAAI,IAAI,GAAwB,GAAI,CAAC,IAAI,CAAC;YAC1C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBAC3B,IAAI,IAAI,CAAC,IAAI,IAAI,KAAK;oBAClB,OAAO,CAAC,GAAG,CAAC,uDAAuD,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAC1F,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,mBAAmB;aACpD;SACJ;aAAM,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,EAAE,EAAC,qDAAqD;YACvF,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,WAAW;gBAAE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC;;gBACrE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,QAAQ,CAAC;SACnD;QACD,QAAQ,MAAM,CAAC,MAAM,EAAE;YACnB,KAAK,WAAW;gBACZ,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,SAAS,CAAC;gBAC5C,MAAM;YACV,KAAK,SAAS;gBACV,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,OAAO,CAAC;gBAC1C,MAAM;SACb;QACD,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU;YAAE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,QAAQ,CAAC;QAC9F,IAAI,MAAM,CAAC,KAAK,KAAK,QAAQ;YAAE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC;IAC5E,CAAC;IAEO,cAAc,CAAC,MAAW,EAAE,GAAwG,EAAE,MAAuB;QACjK,IAAI,MAAM,CAAC,IAAI;YACX,KAAK,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,EAAE;gBACzB,IAAI,GAAG,CAAC,aAAa,KAAK,SAAS,EAAE;oBAEjC;;;;;;uBAMG;oBACH,MAAM,OAAO,GAAY,GAAG,CAAC,KAAM,CAAC,KAAK,CAAC,+EAA+E,CAAC,CAAC;oBAC3H,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,CAAC,GAAG,OAAO,CAAC;oBAE9D,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,CACtC,KAAK,EACL,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CACzD,CAAC;oBAEF,IAAG,YAAY,IAAI,IAAI,EAAE;wBACrB,SAAS,CAAC,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;qBAClE;oBAE2E,GAAI,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBAChH,eAAe,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;iBAExC;qBAAM,IAAI,GAAG,CAAC,aAAa,KAAK,YAAY,EAAE;oBAC3C,IAAI,OAAO,GAAY,GAAG,CAAC,KAAM,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;oBAC7F,IAAI,YAAY,GAAW,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;oBAE5D,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC;iBACnE;aACJ;QAEL,SAAS,eAAe,CAAC,aAAqB,EAAE,YAAoB;YAChE,IAAI,aAAa,IAAI,IAAI,EAAE;gBACvB,IAAI,SAAS,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACzC,IAAI,MAAM,IAAI,IAAI,EAAE;oBAChB,KAAK,IAAI,KAAK,IAAI,MAAM,EAAE;wBACtB,IAAI,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE;4BACrC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;yBAC5D;qBACJ;iBACJ;gBACD,IAAI,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,EAAC,kCAAkC;oBAC7C,GAAI,CAAC,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;iBAC3F;gBACD,IAAI,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAC,gCAAgC;oBACzC,GAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;iBACrF;aACJ;QACL,CAAC;IACL,CAAC;CAEJ;AA7oBD,wBA6oBC"} \ No newline at end of file +{"version":3,"file":"Parser.js","sourceRoot":"","sources":["../src/Parser.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAE/B,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAEzC,MAAa,MAAM;IAMf,YAAY,IAAW;QAEnB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QAErB,qDAAqD;QACrD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAExB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAE1B,yCAAyC;QACzC,yIAAyI;QACzI,kDAAkD;QAClD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAE9B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAE1B,oBAAoB;QACpB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAEjE,qBAAqB;QACrB,MAAM,kBAAkB,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAEvD,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;QAEnE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI;QAEA,IAAI,OAAO,GAAG,EAAE,CAAC;QAEjB,IAAI,MAAM,GAAG,wCAAwC,CAAC;QAEtD,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,GAA4B,EAAE,EAAE;YACtF,OAAO,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAER,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EACtB;YACI,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;YAC7C,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;SACxB;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAEO,YAAY,CAAC,IAAW;QAE5B,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;QAClF,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;QAElF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAElC,IAAI,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAErB,QAAQ,MAAM,CAAC,QAAQ,EACvB;gBACI,KAAK,qCAAqC,CAAC;gBAC3C,KAAK,2CAA2C,CAAC;gBACjD,KAAK,yCAAyC,CAAC;gBAC/C,KAAK,yCAAyC,CAAC;gBAC/C,KAAK,4CAA4C,CAAC;gBAClD,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,qCAAqC,CAAC;gBAC3C,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,kCAAkC,CAAC;gBACxC,KAAK,yCAAyC,CAAC;gBAC/C,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,sCAAsC,CAAC;gBAC5C,KAAK,4CAA4C,CAAC;gBAClD,KAAK,wCAAwC,CAAC;gBAC9C,KAAK,4CAA4C,CAAC;gBAClD,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,uCAAuC,CAAC;gBAC7C,KAAK,2CAA2C,CAAC;gBACjD,KAAK,oCAAoC,CAAC;gBAC1C,KAAK,sCAAsC,CAAC;gBAC5C,KAAK,yCAAyC,CAAC;gBAC/C,KAAK,uCAAuC;oBACxC,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC;oBACtB,MAAM;gBAEV,+BAA+B;gBAC/B,KAAK,mBAAmB,CAAC;gBACzB,KAAK,mBAAmB,CAAC;gBACzB,KAAK,4BAA4B,CAAC;gBAClC,KAAK,gCAAgC,CAAC;gBACtC,KAAK,qBAAqB,CAAC;gBAC3B,KAAK,0BAA0B,CAAC;gBAChC,KAAK,yBAAyB,CAAC;gBAC/B,KAAK,mBAAmB,CAAC;gBACzB,KAAK,4BAA4B,CAAC;gBAClC,KAAK,6BAA6B,CAAC;gBACnC,KAAK,sBAAsB;oBACvB,sDAAsD;oBACtD,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC;oBACvB,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC;oBACrB,MAAM;aACb;YAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,mCAAmC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,mCAAmC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,mCAAmC,CAAC,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EACvP;gBACI,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC;aACzB;YAED,kEAAkE;YAElE,IAAI,GAAwB,CAAC;YAC7B,IAAI,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC;YAE7B,QAAQ,MAAM,CAAC,IAAI,EAAE;gBACjB,KAAK,WAAW;oBACZ,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;oBACnC,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC;oBAC5B,MAAM;gBACV,KAAK,OAAO;oBACR,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;oBAC/B,MAAM;gBACV,KAAK,OAAO;oBACR,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;oBACnC,MAAM;gBACV,KAAK,QAAQ;oBACT,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,EAAE;wBACxB,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;wBAC9B,MAAM;qBACT;gBACL,KAAK,UAAU;oBACX,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;oBAChC,MAAM;gBACV,KAAK,UAAU;oBACX,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;oBAClC,MAAM;gBACV,KAAK,SAAS;oBACV,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;oBACjC,MAAM;gBACV,KAAK,OAAO;oBACR,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;oBAC/B,MAAM;gBACV;oBACI,OAAO,CAAC,GAAG,CAAC,uBAAuB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;oBACnD,MAAM;aACb;YAED,IAAI,GAAG,EACP;gBACI,IAAI,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAC9B;oBACI,OAAO,CAAC,GAAG,CAAC,wCAAwC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;oBACxE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;oBACpB,SAAS;iBACZ;gBAED,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC;gBAEjC,IAAI,MAAM,CAAC,WAAW,EACtB;oBACI,IAAI,SAAS,GAAG,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;oBACvC,GAAG,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;iBACnF;aACJ;SACJ;IACL,CAAC;IAEO,cAAc,CAAC,IAAW;QAE9B,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;QAClF,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/B,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;QAElF,IAAI,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;QAEjC,KAAK,IAAI,MAAM,IAAI,IAAI,EACvB;YACI,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAE3G,IAAI,CAAC,GAAG,EACR;gBACI,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,YAAY,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;gBACzD,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;gBAE3C,SAAS;aACZ;YAED,IAAI,CAAC,MAAM,CAAC,QAAQ,EACpB;gBACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAA8B,CAAC,CAAC;aACtD;iBAED;gBACI,IAAI,iBAAiB,GAAG,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,IAAI,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC;gBAE5H,IAAI,MAAM,GAAG,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAExI,IAAI,CAAC,MAAM,EACX;oBACI,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,YAAY,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;oBACzD,OAAO,CAAC,GAAG,CAAC,mBAAmB,MAAM,CAAC,QAAQ,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,gBAAgB,MAAM,CAAC,QAAQ,wBAAwB,CAAC,CAAC;iBAC3J;gBAED,IAAU,MAAO,CAAC,OAAO,EACzB;oBACU,MAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;iBACnC;qBAED;oBACI,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,YAAY,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;oBACzD,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;oBAC5C,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;iBACvB;gBAEK,GAAI,CAAC,OAAO,GAAG,MAAM,CAAC;gBAE5B,wDAAwD;gBACxD,IAAI,CAAE,MAAc,CAAC,IAAI,KAAK,OAAO,IAAK,MAAc,CAAC,IAAI,KAAK,WAAW,CAAC,IAAK,GAAW,CAAC,IAAI,KAAK,UAAU,EAClH;oBACK,GAAW,CAAC,IAAI,GAAG,QAAQ,CAAC;iBAChC;gBAED,uDAAuD;gBACvD,IAAK,MAAc,CAAC,IAAI,KAAK,WAAW,IAAK,GAAW,CAAC,IAAI,KAAK,UAAU,EAC5E;oBACI,IAAI,MAAM,CAAC,IAAI,IAAI,UAAU,EAC7B;wBACK,GAAW,CAAC,IAAI,GAAG,OAAO,CAAC;qBAC/B;yBAED;wBACK,GAAW,CAAC,IAAI,GAAG,KAAK,CAAC;qBAC7B;iBACJ;aACJ;SACJ;IACL,CAAC;IAEO,kBAAkB,CAAC,IAAW;QAElC,KAAK,IAAI,MAAM,IAAI,IAAI,EACvB;YACI,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAEzG,IAAI,CAAC,GAAG,EACR;gBACI,OAAO,CAAC,GAAG,CAAC,oBAAoB,MAAM,CAAC,QAAQ,MAAM,CAAC,CAAC;gBACvD,SAAS;aACZ;YAED,IAAI,CAAO,GAAI,CAAC,OAAO;gBAAE,SAAS;YAElC,IAAI,MAAM,CAAC,SAAS,EACpB;gBACI,4DAA4D;gBAC5D,IAAI,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAEzC,IAAI,CAAC,IAAI,IAAI,CAAO,IAAK,CAAC,OAAO,EACjC;oBACI,MAAM,IAAI,MAAM,CAAC,QAAQ,0BAA0B,MAAM,CAAC,QAAQ,0BAA0B,CAAC;iBAChG;gBAED,IAAU,IAAK,CAAC,OAAO,CAAC,IAAI,IAAI,WAAW,EAC3C;oBACU,GAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAO,GAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;oBACxE,GAAI,CAAC,OAAO,GAAG,IAAI,CAAC;iBAC7B;aACJ;SACJ;IACL,CAAC;IAEO,cAAc,CAAC,IAAW;QAC9B,KAAK,IAAI,MAAM,IAAI,IAAI,EAAE;YACrB,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACxC,IAAI,CAAC,GAAG,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO;gBAAE,SAAS;YAE9C,IAAI,CAAC,GAAG,GAA2B,CAAC;YAEpC,mBAAmB;YACnB,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;gBAC3C,KAAK,IAAI,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE;oBACjC,IAAI,IAAI,GAAW,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;oBAEjD,IAAI,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA,2EAA2E;oBAEtH,IAAI,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAoD,CAAC;oBAE7F,IAAI,CAAC,QAAQ,EAAE;wBACX,OAAO,CAAC,GAAG,CAAC,kCAAkC,OAAO,QAAQ,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;qBACnF;yBAAM;wBACH,IAAI,QAAQ,CAAC,IAAI,IAAI,OAAO,EAAE;4BAC1B,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;yBACvC;6BAAM;4BACH,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;yBACjD;qBACJ;iBACJ;aACJ;SACJ;IACL,CAAC;IAEO,eAAe,CAAC,MAAW;QAE/B;;;;;;;;;;;;;;;WAeG;QAEC,8CAA8C;QAElD,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAE5C,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,WAAW,CAAC,MAAW;QAC3B,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAExC,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,IAAI,MAAM,CAAC,MAAM,EAAE;YACf,IAAI,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACxC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC7B,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;YAEzB,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,IAAK,CAAC,OAAO,GAAG,GAAG,CAAC;SAC7B;QAED,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAEzC,IAAI,MAAM,CAAC,SAAS;YAChB,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,+BAA+B;QAExG,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,eAAe,CAAC,MAAW;QAC/B,OAAO,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAEO,YAAY,CAAC,MAAW;QAC5B,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAElC,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEjD,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAEvC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,WAAW,CAAC,MAAW;QAE3B,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAElC,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAE9C,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,UAAU,CAAC,MAAW;QAC1B,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAE9C,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,cAAc,CAAC,MAAW;QAC9B,IAAI,UAAU,GAAa,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;QAEzC,IAAI,MAAM,CAAC,OAAO,EAAE;YAChB,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;SAClD;QAED,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;QAC7D,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE5B,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;QAEjD,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,aAAa,CAAC,MAAW;QAC7B,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACtC,IAAI,IAAI,GAAG,IAAI,CAAC;QAEhB,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;YACnC,IAAI,UAAU,GAAG,EAAE,CAAC;YAEpB,KAAK,IAAI,OAAO,IAAI,MAAM,CAAC,UAAU,EAAE;gBACnC,IAAI,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;gBACtC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACtB,IAAI,OAAO,CAAC,WAAW;oBACnB,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;aAC7E;YAED,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YAEzC,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;gBAC3C,IAAI,iBAAiB,GAAG,EAAE,CAAC;gBAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBAC7C,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBAC7E;gBACD,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC7B,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;aACrD;SAEJ;aAAM;YACH,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE;gBACpC,IAAI,UAAU,GAAa,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;gBACzC,IAAI,MAAM,CAAC,OAAO,EAAE;oBAChB,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;iBAClD;gBACD,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;gBACjD,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;aAChC;iBAAM;gBACH,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;aACjC;SACJ;QAED,IAAI,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEhD,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QAEzC,OAAO,KAAK,CAAC;IACjB,CAAC;IAEO,SAAS,CAAC,MAAW,EAAE,GAAyD;QACpF,IAAI,UAAU,GAAoB,EAAE,CAAC;QAErC,IAAI,MAAM,CAAC,IAAI,EAAE;YACb,IAAI,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACjD,IAAI,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;YACzE,IAAI,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAEtD,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC1B;QAED,IAAI,MAAM,CAAC,MAAM,EAAE;YAEf,IAAI,QAAQ,GAAG,KAAK,CAAC;YAErB,GAAG,CAAC,YAAY,GAAG,EAAE,CAAC;YAEtB,KAAK,IAAI,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE;gBAEhC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAClB;oBACI,OAAO,CAAC,GAAG,CAAC,kBAAkB,MAAM,CAAC,QAAQ,QAAQ,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;oBAEnG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;iBAC1B;gBAED,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE;oBAElC,OAAO,CAAC,GAAG,CAAC,yCAAyC,MAAM,CAAC,QAAQ,QAAQ,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;oBAE1H,IAAI,UAAU,GAAG,QAAQ,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;oBAEzG,IAAI,QAAQ,CAAC,WAAW;wBACpB,GAAG,CAAC,YAAY,IAAI,YAAY,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,GAAG,UAAU,CAAC;yBAClH,IAAI,UAAU,CAAC,MAAM;wBACtB,GAAG,CAAC,YAAY,IAAI,YAAY,QAAQ,CAAC,IAAI,GAAG,GAAG,UAAU,CAAC;oBAClE,SAAS;iBACZ;gBAED,IAAI,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC9F,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAEvB,IAAI,QAAQ,IAAI,QAAQ,CAAC,QAAQ,IAAI,IAAI,EAAE;oBACvC,OAAO,CAAC,GAAG,CAAC,+CAA+C,QAAQ,CAAC,IAAI,UAAU,MAAM,CAAC,QAAQ,QAAQ,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;oBACvJ,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC;iBAC5B;gBAED,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;gBAEnC,QAAQ,GAAG,QAAQ,IAAI,QAAQ,CAAC,QAAQ,KAAK,IAAI,CAAC;gBAElD,IAAI,UAAU,GAAG,QAAQ,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBAEzG,IAAI,QAAQ,CAAC,WAAW;oBACpB,GAAG,CAAC,YAAY,IAAI,YAAY,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,GAAG,UAAU,CAAC;qBAClH,IAAI,UAAU,CAAC,MAAM;oBACtB,GAAG,CAAC,YAAY,IAAI,YAAY,QAAQ,CAAC,IAAI,GAAG,GAAG,UAAU,CAAC;aACrE;SACJ;QAED,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC;IAChC,CAAC;IAEO,SAAS,CAAC,OAAY,EAAE,YAAY,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI;QACxD,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;YAC3B,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;SACvB;aAAM;YACH,IAAI,KAAK,GAAG,EAAE,CAAC;YACf,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE;gBAEjC,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;gBAElC,IAAI,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;gBAErE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACpB;YACD,IAAI,OAAO,CAAC,QAAQ,EAAE;gBAClB,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;aAC5B;YACD,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC;gBAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;;gBAClC,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACvC;IACL,CAAC;IAEO,eAAe,CAAC,IAAY;QAChC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE;YACzB,IAAI,GAAY,IAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAChD;QACD,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,KAAK,oBAAoB,EAAE;YAC3D,IAAI,GAAY,IAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAC/C;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,eAAe,CAAC,IAAY;QAChC,IAAI,IAAI,KAAK,OAAO;YAAE,OAAO,QAAQ,CAAC;QACtC,IAAI,IAAI,KAAK,UAAU;YAAE,OAAO,UAAU,CAAC;QAC3C,IAAI,IAAI,KAAK,oBAAoB;YAAE,OAAO,YAAY,CAAC;QACvD,IAAI,IAAI,KAAK,OAAO;YAAE,OAAO,OAAO,CAAC;QAErC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;YAC3B,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;YAE1C,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;gBACvB,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;aAClD;SACJ;aAAM,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YACnC,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YAE3C,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;gBACvB,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE;oBAC/B,IAAI,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBAClC,OAAO,UAAU,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;iBAC1F;qBAAM;oBACH,OAAO,mBAAmB,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;iBACjE;aACJ;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,YAAY,CAAC,MAAW,EAAE,GAAwC;QACtE,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC;QACtC,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,EAAE;YAC1B,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC;YACrC,IAAI,IAAI,GAAwB,GAAI,CAAC,IAAI,CAAC;YAC1C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBAC3B,IAAI,IAAI,CAAC,IAAI,IAAI,KAAK;oBAClB,OAAO,CAAC,GAAG,CAAC,uDAAuD,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAC1F,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,mBAAmB;aACpD;SACJ;aAAM,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,EAAE,EAAC,qDAAqD;YACvF,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,WAAW;gBAAE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC;;gBACrE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,QAAQ,CAAC;SACnD;QACD,QAAQ,MAAM,CAAC,MAAM,EAAE;YACnB,KAAK,WAAW;gBACZ,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,SAAS,CAAC;gBAC5C,MAAM;YACV,KAAK,SAAS;gBACV,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,OAAO,CAAC;gBAC1C,MAAM;SACb;QACD,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU;YAAE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,QAAQ,CAAC;QAC9F,IAAI,MAAM,CAAC,KAAK,KAAK,QAAQ;YAAE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC;IAC5E,CAAC;IAEO,cAAc,CAAC,MAAW,EAAE,GAAwG,EAAE,MAAuB;QACjK,IAAI,MAAM,CAAC,IAAI;YACX,KAAK,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,EAAE;gBACzB,IAAI,GAAG,CAAC,aAAa,KAAK,SAAS,EAAE;oBAEjC;;;;;;uBAMG;oBACH,MAAM,OAAO,GAAY,GAAG,CAAC,KAAM,CAAC,KAAK,CAAC,+EAA+E,CAAC,CAAC;oBAC3H,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,CAAC,GAAG,OAAO,CAAC;oBAE9D,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,CACtC,KAAK,EACL,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CACzD,CAAC;oBAEF,IAAG,YAAY,IAAI,IAAI,EAAE;wBACrB,SAAS,CAAC,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;qBAClE;oBAE2E,GAAI,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBAChH,eAAe,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;iBAExC;qBAAM,IAAI,GAAG,CAAC,aAAa,KAAK,YAAY,EAAE;oBAC3C,IAAI,OAAO,GAAY,GAAG,CAAC,KAAM,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;oBAC7F,IAAI,YAAY,GAAW,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;oBAE5D,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC;iBACnE;aACJ;QAEL,SAAS,eAAe,CAAC,aAAqB,EAAE,YAAoB;YAChE,IAAI,aAAa,IAAI,IAAI,EAAE;gBACvB,IAAI,SAAS,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACzC,IAAI,MAAM,IAAI,IAAI,EAAE;oBAChB,KAAK,IAAI,KAAK,IAAI,MAAM,EAAE;wBACtB,IAAI,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE;4BACrC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;yBAC5D;qBACJ;iBACJ;gBACD,IAAI,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,EAAC,kCAAkC;oBAC7C,GAAI,CAAC,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;iBAC3F;gBACD,IAAI,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAC,gCAAgC;oBACzC,GAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;iBACrF;aACJ;QACL,CAAC;IACL,CAAC;CAEJ;AA7oBD,wBA6oBC"} \ No newline at end of file diff --git a/types/phaser.d.ts b/types/phaser.d.ts index 6b465b65f..7c9b0e9ef 100644 --- a/types/phaser.d.ts +++ b/types/phaser.d.ts @@ -1,4 +1,3 @@ -// DO NOT EDIT THIS FILE! It was generated by running `npm run tsgen` /// declare type CameraRotateCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number, angle: number)=>void; @@ -632,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. * @@ -656,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. @@ -2225,7 +2224,7 @@ declare namespace Phaser { * This can happen either as a result of an animation instance being added to the Animation Manager, * or the Animation Manager creating a new animation directly. */ - const ADD_ANIMATION: string; + const ADD_ANIMATION: any; /** * The Animation Complete Event. @@ -2252,7 +2251,7 @@ declare namespace Phaser { * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. */ - const ANIMATION_COMPLETE: string; + const ANIMATION_COMPLETE: any; /** * The Animation Complete Dynamic Key Event. @@ -2283,7 +2282,7 @@ declare namespace Phaser { * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. */ - const ANIMATION_COMPLETE_KEY: string; + const ANIMATION_COMPLETE_KEY: any; /** * The Animation Repeat Event. @@ -2307,7 +2306,7 @@ declare namespace Phaser { * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. */ - const ANIMATION_REPEAT: string; + const ANIMATION_REPEAT: any; /** * The Animation Restart Event. @@ -2329,7 +2328,7 @@ declare namespace Phaser { * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. */ - const ANIMATION_RESTART: string; + const ANIMATION_RESTART: any; /** * The Animation Start Event. @@ -2352,7 +2351,7 @@ declare namespace Phaser { * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. */ - const ANIMATION_START: string; + const ANIMATION_START: any; /** * The Animation Stop Event. @@ -2375,7 +2374,7 @@ declare namespace Phaser { * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. */ - const ANIMATION_STOP: string; + const ANIMATION_STOP: any; /** * The Animation Update Event. @@ -2402,7 +2401,7 @@ declare namespace Phaser { * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. */ - const ANIMATION_UPDATE: string; + const ANIMATION_UPDATE: any; /** * The Pause All Animations Event. @@ -2412,14 +2411,14 @@ declare namespace Phaser { * When this happens all current animations will stop updating, although it doesn't necessarily mean * that the game has paused as well. */ - const PAUSE_ALL: string; + const PAUSE_ALL: any; /** * The Remove Animation Event. * * This event is dispatched when an animation is removed from the global Animation Manager. */ - const REMOVE_ANIMATION: string; + const REMOVE_ANIMATION: any; /** * The Resume All Animations Event. @@ -2428,7 +2427,7 @@ declare namespace Phaser { * * When this happens all current animations will continue updating again. */ - const RESUME_ALL: string; + const RESUME_ALL: any; } @@ -2613,14 +2612,14 @@ declare namespace Phaser { * * This event is dispatched by any Cache that extends the BaseCache each time a new object is added to it. */ - const ADD: string; + const ADD: any; /** * The Cache Remove Event. * * This event is dispatched by any Cache that extends the BaseCache each time an object is removed from it. */ - const REMOVE: string; + const REMOVE: any; } @@ -2808,12 +2807,6 @@ declare namespace Phaser { */ renderList: Phaser.GameObjects.GameObject[]; - /** - * Is this Camera a Scene Camera? (which is the default), or a Camera - * belonging to a Texture? - */ - isSceneCamera: boolean; - /** * Adds the given Game Object to this cameras render list. * @@ -3022,9 +3015,8 @@ declare namespace Phaser { /** * Sets the Scene the Camera is bound to. * @param scene The Scene the camera is bound to. - * @param isSceneCamera Is this Camera being used for a Scene (true) or a Texture? (false) Default true. */ - setScene(scene: Phaser.Scene, isSceneCamera?: boolean): this; + setScene(scene: Phaser.Scene): this; /** * Set the position of where the Camera is looking within the game. @@ -3123,13 +3115,6 @@ declare namespace Phaser { */ protected update(time: number, delta: number): void; - /** - * Set if this Camera is being used as a Scene Camera, or a Texture - * Camera. - * @param value Is this being used as a Scene Camera, or a Texture camera? - */ - setIsSceneCamera(value: boolean): void; - /** * Destroys this Camera instance and its internal properties and references. * Once destroyed you cannot use this Camera again, even if re-added to a Camera Manager. @@ -4600,7 +4585,7 @@ declare namespace Phaser { * * This event is dispatched by a Camera instance when it is destroyed by the Camera Manager. */ - const DESTROY: string; + const DESTROY: any; /** * The Camera Fade In Complete Event. @@ -4609,7 +4594,7 @@ declare namespace Phaser { * * Listen to it from a Camera instance using `Camera.on('camerafadeincomplete', listener)`. */ - const FADE_IN_COMPLETE: string; + const FADE_IN_COMPLETE: any; /** * The Camera Fade In Start Event. @@ -4618,7 +4603,7 @@ declare namespace Phaser { * * Listen to it from a Camera instance using `Camera.on('camerafadeinstart', listener)`. */ - const FADE_IN_START: string; + const FADE_IN_START: any; /** * The Camera Fade Out Complete Event. @@ -4627,7 +4612,7 @@ declare namespace Phaser { * * Listen to it from a Camera instance using `Camera.on('camerafadeoutcomplete', listener)`. */ - const FADE_OUT_COMPLETE: string; + const FADE_OUT_COMPLETE: any; /** * The Camera Fade Out Start Event. @@ -4636,21 +4621,21 @@ declare namespace Phaser { * * Listen to it from a Camera instance using `Camera.on('camerafadeoutstart', listener)`. */ - const FADE_OUT_START: string; + const FADE_OUT_START: any; /** * The Camera Flash Complete Event. * * This event is dispatched by a Camera instance when the Flash Effect completes. */ - const FLASH_COMPLETE: string; + const FLASH_COMPLETE: any; /** * The Camera Flash Start Event. * * This event is dispatched by a Camera instance when the Flash Effect starts. */ - const FLASH_START: string; + const FLASH_START: any; /** * The Camera Follower Update Event. @@ -4661,21 +4646,21 @@ declare namespace Phaser { * * Listen to it from a Camera instance using: `camera.on('followupdate', listener)`. */ - const FOLLOW_UPDATE: string; + const FOLLOW_UPDATE: any; /** * The Camera Pan Complete Event. * * This event is dispatched by a Camera instance when the Pan Effect completes. */ - const PAN_COMPLETE: string; + const PAN_COMPLETE: any; /** * The Camera Pan Start Event. * * This event is dispatched by a Camera instance when the Pan Effect starts. */ - const PAN_START: string; + const PAN_START: any; /** * The Camera Post-Render Event. @@ -4685,7 +4670,7 @@ declare namespace Phaser { * * Listen to it from a Camera instance using: `camera.on('postrender', listener)`. */ - const POST_RENDER: string; + const POST_RENDER: any; /** * The Camera Pre-Render Event. @@ -4695,49 +4680,49 @@ declare namespace Phaser { * * Listen to it from a Camera instance using: `camera.on('prerender', listener)`. */ - const PRE_RENDER: string; + const PRE_RENDER: any; /** * The Camera Rotate Complete Event. * * This event is dispatched by a Camera instance when the Rotate Effect completes. */ - const ROTATE_COMPLETE: string; + const ROTATE_COMPLETE: any; /** * The Camera Rotate Start Event. * * This event is dispatched by a Camera instance when the Rotate Effect starts. */ - const ROTATE_START: string; + const ROTATE_START: any; /** * The Camera Shake Complete Event. * * This event is dispatched by a Camera instance when the Shake Effect completes. */ - const SHAKE_COMPLETE: string; + const SHAKE_COMPLETE: any; /** * The Camera Shake Start Event. * * This event is dispatched by a Camera instance when the Shake Effect starts. */ - const SHAKE_START: string; + const SHAKE_START: any; /** * The Camera Zoom Complete Event. * * This event is dispatched by a Camera instance when the Zoom Effect completes. */ - const ZOOM_COMPLETE: string; + const ZOOM_COMPLETE: any; /** * The Camera Zoom Start Event. * * This event is dispatched by a Camera instance when the Zoom Effect starts. */ - const ZOOM_START: string; + const ZOOM_START: any; } @@ -5833,148 +5818,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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * The Game Resume Event. - * - * This event is dispatched when the game loop leaves a paused state and resumes running. - */ - const RESUME: string; - - /** - * 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: string; - - /** - * 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: string; - - } - /** * 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. @@ -6318,6 +6161,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 { @@ -6882,6 +6867,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. @@ -7167,135 +7281,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 { @@ -7561,7 +7546,7 @@ declare namespace Phaser { * This event is dispatched for all items that change in the Data Manager. * To listen for the change of a specific item, use the `CHANGE_DATA_KEY_EVENT` event. */ - const CHANGE_DATA: string; + const CHANGE_DATA: any; /** * The Change Data Key Event. @@ -7573,14 +7558,14 @@ declare namespace Phaser { * where `key` is the unique string key of the data item. For example, if you have a data item stored called `gold` * then you can listen for `sprite.data.on('changedata-gold')`. */ - const CHANGE_DATA_KEY: string; + const CHANGE_DATA_KEY: any; /** * The Data Manager Destroy Event. * * The Data Manager will listen for the destroy event from its parent, and then close itself down. */ - const DESTROY: string; + const DESTROY: any; /** * The Remove Data Event. @@ -7590,7 +7575,7 @@ declare namespace Phaser { * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for * the removal of a data item on a Game Object you would use: `sprite.data.on('removedata', listener)`. */ - const REMOVE_DATA: string; + const REMOVE_DATA: any; /** * The Set Data Event. @@ -7600,7 +7585,7 @@ declare namespace Phaser { * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for * the addition of a new data item on a Game Object you would use: `sprite.data.on('setdata', listener)`. */ - const SET_DATA: string; + const SET_DATA: any; } @@ -8015,6 +8000,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. @@ -8816,16 +9036,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. @@ -8854,6 +9064,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) @@ -8880,14 +9100,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. * @@ -8918,6 +9130,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. @@ -8927,160 +9147,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. @@ -9114,43 +9180,84 @@ declare namespace Phaser { class BitmapMask { /** * - * @param scene The Scene to which this mask is being added. - * @param maskObject The Game Object that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. - * @param x If creating a Game Object, the horizontal position in the world. - * @param y If creating a Game Object, the vertical position in the world. - * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. - * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. + * @param scene The Scene which this Bitmap Mask will be used in. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. */ - constructor(scene: Phaser.Scene, maskObject?: Phaser.GameObjects.GameObject, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame); + constructor(scene: Phaser.Scene, renderable: Phaser.GameObjects.GameObject); /** - * The Game Object that is used as the mask. Must use a texture, such as a Sprite. + * A reference to either the Canvas or WebGL Renderer that this Mask is using. + */ + renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + + /** + * A renderable Game Object that uses a texture, such as a Sprite. */ bitmapMask: Phaser.GameObjects.GameObject; + /** + * The texture used for the masks framebuffer. + */ + maskTexture: WebGLTexture; + + /** + * The texture used for the main framebuffer. + */ + mainTexture: WebGLTexture; + + /** + * Whether the Bitmap Mask is dirty and needs to be updated. + */ + dirty: boolean; + + /** + * The framebuffer to which a masked Game Object is rendered. + */ + mainFramebuffer: WebGLFramebuffer; + + /** + * The framebuffer to which the Bitmap Mask's masking Game Object is rendered. + */ + maskFramebuffer: WebGLFramebuffer; + /** * Whether to invert the masks alpha. * * If `true`, the alpha of the masking pixel will be inverted before it's multiplied with the masked pixel. - * * Essentially, this means that a masked area will be visible only if the corresponding area in the mask is invisible. */ invertAlpha: boolean; /** - * Is this mask a stencil mask? This is false by default and should not be changed. + * Is this mask a stencil mask? */ readonly isStencil: boolean; /** - * Sets a new Game Object for this Bitmap Mask to use. - * - * The Game Object must have a texture, such as a Sprite. - * - * You can update the source Game Object being used as the mask as often as you like. - * @param maskObject The Game Object that will be used as the mask. Must have a texture, such as a Sprite. + * The Scene which this Bitmap Mask will be used in. */ - setBitmap(maskObject: Phaser.GameObjects.GameObject): void; + scene: Phaser.Scene; + + /** + * Creates the WebGL Texture2D objects and Framebuffers required for this + * mask. If this mask has already been created, then `clearMask` is called first. + */ + createMask(): void; + + /** + * Deletes the `mainTexture` and `maskTexture` WebGL Textures and deletes + * the `mainFramebuffer` and `maskFramebuffer` too, nulling all references. + * + * This is called when this mask is destroyed, or if you try to creat a new + * mask from this object when one is already set. + */ + clearMask(): void; + + /** + * Sets a new masking Game Object for the Bitmap Mask. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + setBitmap(renderable: Phaser.GameObjects.GameObject): void; /** * Prepares the WebGL Renderer to render a Game Object with this mask applied. @@ -9167,10 +9274,8 @@ declare namespace Phaser { * * This resets the previously bound framebuffer and switches the WebGL Renderer to the Bitmap Mask Pipeline, which uses a special fragment shader to apply the masking effect. * @param renderer The WebGL Renderer to clean up. - * @param camera The Camera to render to. - * @param renderTarget Optional WebGL RenderTarget. */ - postRenderWebGL(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer, camera: Phaser.Cameras.Scene2D.Camera, renderTarget?: Phaser.Renderer.WebGL.RenderTarget): void; + postRenderWebGL(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer): void; /** * This is a NOOP method. Bitmap Masks are not supported by the Canvas Renderer. @@ -9303,87 +9408,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. * @@ -9645,6 +9669,1721 @@ 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 | null; + + /** + * 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 | null; + + /** + * 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. + * @param fromScene `True` if this Game Object is being destroyed by the Scene, `false` if not. Default false. + */ + destroy(fromScene?: boolean): 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; + + /** + * Static method called directly by the Game Object creator functions. + * With this method you can register a custom GameObject factory in the GameObjectCreator, + * providing a name (`factoryType`) and the constructor (`factoryFunction`) in order + * to be called when you invoke Phaser.Scene.make[ factoryType ] method. + * @param factoryType The key of the factory that you will use to call to Phaser.Scene.make[ factoryType ] method. + * @param factoryFunction The constructor function to be called when you invoke to the Phaser.Scene.make method. + */ + static register(factoryType: string, factoryFunction: Function): void; + + /** + * Static method called directly by the Game Object Creator functions. + * + * With this method you can remove a custom Game Object Creator that has been previously + * registered in the Game Object Creator. Pass in its `factoryType` in order to remove it. + * @param factoryType The key of the factory that you want to remove from the GameObjectCreator. + */ + static remove(factoryType: string): void; + + /** + * 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: Phaser.Types.GameObjects.Sprite.SpriteConfig, 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: Phaser.Types.GameObjects.Container.ContainerConfig, 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: Phaser.Types.GameObjects.Graphics.Options, 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: Phaser.Types.GameObjects.Sprite.SpriteConfig, 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: Phaser.Types.GameObjects.Sprite.SpriteConfig, 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: Phaser.Types.GameObjects.Mesh.MeshConfig, 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: Phaser.Types.GameObjects.Particles.ParticleEmitterManagerConfig, 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: Phaser.Types.GameObjects.Rope.RopeConfig, 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: Phaser.Types.GameObjects.Shader.ShaderConfig, 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: Phaser.Types.GameObjects.Video.VideoConfig, 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: Phaser.Types.GameObjects.Zone.ZoneConfig): 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; + + /** + * Creates a new TweenChain object and returns it, without adding it to the Tween Manager. + * + * Note: This method will only be available if Tweens have been built into Phaser. + * @param config The TweenChain configuration. + */ + tweenchain(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.TweenChain; + + } + + /** + * 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[] | Phaser.Types.GameObjects.Group.GroupCreateConfig, 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 color 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; + + /** + * Creates a new TweenChain object and adds it to the Tween Manager. + * + * Note: This method will only be available if Tweens have been built into Phaser. + * @param config The TweenChain configuration. + */ + tweenchain(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.TweenChain; + + } + + /** + * 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): Phaser.Types.GameObjects.BitmapText.BitmapFontData; + + /** + * 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. * @@ -9810,7 +11549,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -9825,7 +11563,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -9834,7 +11572,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -9848,9 +11585,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -9919,7 +11656,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -10192,19 +11929,17 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. + * The Frame has to belong to the current Texture being used. * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * It can be either a string or an index. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param frame The name or index of the frame within the Texture. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -10505,72 +12240,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): Phaser.Types.GameObjects.BitmapText.BitmapFontData; - - } - /** * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. * @@ -11020,7 +12689,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -11035,7 +12703,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -11044,7 +12712,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -11058,9 +12725,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -11129,7 +12796,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -11402,19 +13069,17 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. + * The Frame has to belong to the current Texture being used. * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * It can be either a string or an index. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param frame The name or index of the frame within the Texture. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -11868,7 +13533,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -11883,7 +13547,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -11892,7 +13556,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -11906,9 +13569,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -11977,7 +13640,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -12272,19 +13935,17 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. + * The Frame has to belong to the current Texture being used. * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * It can be either a string or an index. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param frame The name or index of the frame within the Texture. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; /** * A property indicating that a Game Object has this component. @@ -12649,21 +14310,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. @@ -12753,7 +14399,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -12768,7 +14413,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. * @@ -12776,7 +14421,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -12790,9 +14434,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; } /** @@ -12936,6 +14580,52 @@ declare namespace Phaser { setDepth(value: number): this; } + /** + * Provides methods used for setting the FX values of a Game Object. + * Should be applied as a mixin and not used directly. + */ + interface FX { + /** + * The amount of extra padding to be applied to this Game Object + * when it is being rendered by a SpriteFX Pipeline. + * + * Lots of FX require additional spacing added to the texture the + * Game Object uses, for example a glow or shadow effect, and this + * method allows you to control how much extra padding is included + * in addition to the texture size. + */ + fxPadding: number; + /** + * Sets the amount of extra padding to be applied to this Game Object + * when it is being rendered by a SpriteFX Pipeline. + * + * Lots of FX require additional spacing added to the texture the + * Game Object uses, for example a glow or shadow effect, and this + * method allows you to control how much extra padding is included + * in addition to the texture size. + * @param padding The amount of padding to add to the texture. Default 0. + */ + setFXPadding(padding?: number): this; + /** + * This callback is invoked when this Game Object is copied by a SpriteFX Pipeline. + * + * This happens when the pipeline uses its `copySprite` method. + * + * It's invoked prior to the copy, allowing you to set shader uniforms, etc on the pipeline. + * @param pipeline The SpriteFX Pipeline that invoked this callback. + */ + onFXCopy(pipeline: Phaser.Renderer.WebGL.Pipelines.SpriteFXPipeline): void; + /** + * This callback is invoked when this Game Object is rendered by a SpriteFX Pipeline. + * + * This happens when the pipeline uses its `drawSprite` method. + * + * It's invoked prior to the draw, allowing you to set shader uniforms, etc on the pipeline. + * @param pipeline The SpriteFX Pipeline that invoked this callback. + */ + onFX(pipeline: Phaser.Renderer.WebGL.Pipelines.SpriteFXPipeline): void; + } + /** * Provides methods used for visually flipping a Game Object. * Should be applied as a mixin and not used directly. @@ -12999,52 +14689,6 @@ declare namespace Phaser { resetFlip(): this; } - /** - * Provides methods used for setting the FX values of a Game Object. - * Should be applied as a mixin and not used directly. - */ - interface FX { - /** - * The amount of extra padding to be applied to this Game Object - * when it is being rendered by a SpriteFX Pipeline. - * - * Lots of FX require additional spacing added to the texture the - * Game Object uses, for example a glow or shadow effect, and this - * method allows you to control how much extra padding is included - * in addition to the texture size. - */ - fxPadding: number; - /** - * Sets the amount of extra padding to be applied to this Game Object - * when it is being rendered by a SpriteFX Pipeline. - * - * Lots of FX require additional spacing added to the texture the - * Game Object uses, for example a glow or shadow effect, and this - * method allows you to control how much extra padding is included - * in addition to the texture size. - * @param padding The amount of padding to add to the texture. Default 0. - */ - setFXPadding(padding?: number): this; - /** - * This callback is invoked when this Game Object is copied by a SpriteFX Pipeline. - * - * This happens when the pipeline uses its `copySprite` method. - * - * It's invoked prior to the copy, allowing you to set shader uniforms, etc on the pipeline. - * @param pipeline The SpriteFX Pipeline that invoked this callback. - */ - onFXCopy(pipeline: Phaser.Renderer.WebGL.Pipelines.SpriteFXPipeline): void; - /** - * This callback is invoked when this Game Object is rendered by a SpriteFX Pipeline. - * - * This happens when the pipeline uses its `drawSprite` method. - * - * It's invoked prior to the draw, allowing you to set shader uniforms, etc on the pipeline. - * @param pipeline The SpriteFX Pipeline that invoked this callback. - */ - onFX(pipeline: Phaser.Renderer.WebGL.Pipelines.SpriteFXPipeline): void; - } - /** * Provides methods used for obtaining the bounds of a Game Object. * Should be applied as a mixin and not used directly. @@ -13161,7 +14805,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -13574,19 +15218,17 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. + * The Frame has to belong to the current Texture being used. * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * It can be either a string or an index. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param frame The name or index of the frame within the Texture. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; } /** @@ -13646,19 +15288,17 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. + * The Frame has to belong to the current Texture being used. * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * It can be either a string or an index. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param frame The name or index of the frame within the Texture. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; } /** @@ -13963,11 +15603,6 @@ declare namespace Phaser { */ decomposedMatrix: object; - /** - * The temporary quad value cache. - */ - quad: Float32Array; - /** * The Scale X value. */ @@ -14176,20 +15811,6 @@ declare namespace Phaser { */ applyInverse(x: number, y: number, output?: Phaser.Math.Vector2): Phaser.Math.Vector2; - /** - * Performs the 8 calculations required to create the vertices of - * a quad based on this matrix and the given x/y/xw/yh values. - * - * The result is stored in `TransformMatrix.quad`, which is returned - * from this method. - * @param x The x value. - * @param y The y value. - * @param xw The xw value. - * @param yh The yh value. - * @param roundPixels Pass the results via Math.round? - */ - setQuad(x: number, y: number, xw: number, yh: number, roundPixels: boolean): number; - /** * Returns the X component of this matrix multiplied by the given values. * This is the same as `x * a + y * c + e`. @@ -14823,7 +16444,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -14838,7 +16458,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -14847,7 +16467,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -14861,9 +16480,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The native (un-scaled) width of this Game Object. @@ -14992,7 +16611,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -15328,65 +16947,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. * @@ -15859,7 +17419,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -15874,7 +17433,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -15883,7 +17442,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -15897,9 +17455,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -16249,7 +17807,7 @@ declare namespace Phaser { * * Listen for it on a Game Object instance using `GameObject.on('addedtoscene', listener)`. */ - const ADDED_TO_SCENE: string; + const ADDED_TO_SCENE: any; /** * The Game Object Destroy Event. @@ -16258,7 +17816,7 @@ declare namespace Phaser { * * Listen for it on a Game Object instance using `GameObject.on('destroy', listener)`. */ - const DESTROY: string; + const DESTROY: any; /** * The Game Object Removed from Scene Event. @@ -16267,7 +17825,7 @@ declare namespace Phaser { * * Listen for it on a Game Object instance using `GameObject.on('removedfromscene', listener)`. */ - const REMOVED_FROM_SCENE: string; + const REMOVED_FROM_SCENE: any; /** * The Video Game Object Complete Event. @@ -16283,7 +17841,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('complete', listener)`. */ - const VIDEO_COMPLETE: string; + const VIDEO_COMPLETE: any; /** * The Video Game Object Created Event. @@ -16294,7 +17852,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('created', listener)`. */ - const VIDEO_CREATED: string; + const VIDEO_CREATED: any; /** * The Video Game Object Error Event. @@ -16303,7 +17861,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('error', listener)`. */ - const VIDEO_ERROR: string; + const VIDEO_ERROR: any; /** * The Video Game Object Loop Event. @@ -16319,7 +17877,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('loop', listener)`. */ - const VIDEO_LOOP: string; + const VIDEO_LOOP: any; /** * The Video Game Object Play Event. @@ -16331,7 +17889,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('play', listener)`. */ - const VIDEO_PLAY: string; + const VIDEO_PLAY: any; /** * The Video Game Object Seeked Event. @@ -16340,7 +17898,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('seeked', listener)`. */ - const VIDEO_SEEKED: string; + const VIDEO_SEEKED: any; /** * The Video Game Object Seeking Event. @@ -16350,7 +17908,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('seeking', listener)`. */ - const VIDEO_SEEKING: string; + const VIDEO_SEEKING: any; /** * The Video Game Object Stopped Event. @@ -16360,7 +17918,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('stop', listener)`. */ - const VIDEO_STOP: string; + const VIDEO_STOP: any; /** * The Video Game Object Timeout Event. @@ -16370,7 +17928,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('timeout', listener)`. */ - const VIDEO_TIMEOUT: string; + const VIDEO_TIMEOUT: any; /** * The Video Game Object Unlocked Event. @@ -16380,7 +17938,7 @@ declare namespace Phaser { * * Listen for it from a Video Game Object instance using `Video.on('unlocked', listener)`. */ - const VIDEO_UNLOCKED: string; + const VIDEO_UNLOCKED: any; } @@ -16470,7 +18028,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -16485,7 +18042,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -16494,7 +18051,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -16508,9 +18064,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -16816,19 +18372,17 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. + * The Frame has to belong to the current Texture being used. * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * It can be either a string or an index. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param frame The name or index of the frame within the Texture. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -17129,1568 +18683,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 | null; - - /** - * 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 | null; - - /** - * 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. - * @param fromScene `True` if this Game Object is being destroyed by the Scene, `false` if not. Default false. - */ - destroy(fromScene?: boolean): 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: Phaser.Types.GameObjects.Sprite.SpriteConfig, 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: Phaser.Types.GameObjects.Container.ContainerConfig, 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; - - /** - * Static method called directly by the Game Object creator functions. - * With this method you can register a custom GameObject factory in the GameObjectCreator, - * providing a name (`factoryType`) and the constructor (`factoryFunction`) in order - * to be called when you invoke Phaser.Scene.make[ factoryType ] method. - * @param factoryType The key of the factory that you will use to call to Phaser.Scene.make[ factoryType ] method. - * @param factoryFunction The constructor function to be called when you invoke to the Phaser.Scene.make method. - */ - static register(factoryType: string, factoryFunction: Function): void; - - /** - * Static method called directly by the Game Object Creator functions. - * - * With this method you can remove a custom Game Object Creator that has been previously - * registered in the Game Object Creator. Pass in its `factoryType` in order to remove it. - * @param factoryType The key of the factory that you want to remove from the GameObjectCreator. - */ - static remove(factoryType: string): void; - - /** - * 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: Phaser.Types.GameObjects.Graphics.Options, 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: Phaser.Types.GameObjects.Sprite.SpriteConfig, 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: Phaser.Types.GameObjects.Sprite.SpriteConfig, 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: Phaser.Types.GameObjects.Mesh.MeshConfig, 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: Phaser.Types.GameObjects.Particles.ParticleEmitterManagerConfig, 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: Phaser.Types.GameObjects.Rope.RopeConfig, 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: Phaser.Types.GameObjects.Shader.ShaderConfig, 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: Phaser.Types.GameObjects.Video.VideoConfig, 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: Phaser.Types.GameObjects.Zone.ZoneConfig): 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; - - /** - * Creates a new TweenChain object and returns it, without adding it to the Tween Manager. - * - * Note: This method will only be available if Tweens have been built into Phaser. - * @param config The TweenChain configuration. - */ - tweenchain(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.TweenChain; - - } - - /** - * 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; - - /** - * A Bitmap Mask combines the alpha (opacity) of a masked pixel with the alpha of another pixel. - * Unlike the Geometry Mask, which is a clipping path, a Bitmap Mask behaves like an alpha mask, - * not a clipping path. It is only available when using the WebGL Renderer. - * - * A Bitmap Mask can use any Game Object to determine the alpha of each pixel of the masked Game Object(s). - * For any given point of a masked Game Object's texture, the pixel's alpha will be multiplied by the alpha - * of the pixel at the same position in the Bitmap Mask's Game Object. The color of the pixel from the - * Bitmap Mask doesn't matter. - * - * For example, if a pure blue pixel with an alpha of 0.95 is masked with a pure red pixel with an - * alpha of 0.5, the resulting pixel will be pure blue with an alpha of 0.475. Naturally, this means - * that a pixel in the mask with an alpha of 0 will hide the corresponding pixel in all masked Game Objects - * A pixel with an alpha of 1 in the masked Game Object will receive the same alpha as the - * corresponding pixel in the mask. - * - * Note: You cannot combine Bitmap Masks and Blend Modes on the same Game Object. You can, however, - * combine Geometry Masks and Blend Modes together. - * - * The Bitmap Mask's location matches the location of its Game Object, not the location of the - * masked objects. Moving or transforming the underlying Game Object will change the mask - * (and affect the visibility of any masked objects), whereas moving or transforming a masked object - * will not affect the mask. - * - * The Bitmap Mask will not render its Game Object by itself. If the Game Object is not in a - * Scene's display list, it will only be used for the mask and its full texture will not be directly - * visible. Adding the underlying Game Object to a Scene will not cause any problems - it will - * render as a normal Game Object and will also serve as a mask. - * @param maskObject The Game Object that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. - * @param x If creating a Game Object, the horizontal position in the world. - * @param y If creating a Game Object, the vertical position in the world. - * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. - * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. - */ - bitmapMask(maskObject?: Phaser.GameObjects.GameObject, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; - - /** - * 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[] | Phaser.Types.GameObjects.Group.GroupCreateConfig, 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 color 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; - - /** - * Creates a new TweenChain object and adds it to the Tween Manager. - * - * Note: This method will only be available if Tweens have been built into Phaser. - * @param config The TweenChain configuration. - */ - tweenchain(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.TweenChain; - - } - - /** - * 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 @@ -19262,7 +19254,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -19277,7 +19268,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -19286,7 +19277,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -19300,9 +19290,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -19371,7 +19361,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -20415,7 +20405,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -20430,7 +20419,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -20439,7 +20428,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -20453,9 +20441,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -20709,7 +20697,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -21098,19 +21086,17 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. + * The Frame has to belong to the current Texture being used. * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * It can be either a string or an index. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param frame The name or index of the frame within the Texture. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -21883,7 +21869,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -21898,7 +21883,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -21907,7 +21892,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -21921,9 +21905,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -21992,7 +21976,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -23286,7 +23270,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -23301,7 +23284,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -23310,7 +23293,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -23324,9 +23306,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -23395,7 +23377,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -23631,19 +23613,17 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. + * The Frame has to belong to the current Texture being used. * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * It can be either a string or an index. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param frame The name or index of the frame within the Texture. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; /** * A property indicating that a Game Object has this component. @@ -23900,1009 +23880,6 @@ declare namespace Phaser { } - /** - * TODO - */ - class NineSlice extends Phaser.GameObjects.RenderTexture implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Crop, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.FX, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Tint, 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 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. - */ - constructor(scene: Phaser.Scene, x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | 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. - * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. - * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. - * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. - */ - setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: 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; - - /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaTopLeft: number; - - /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaTopRight: number; - - /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaBottomLeft: number; - - /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaBottomRight: 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: - * - * * NORMAL - * * 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 | 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: - * - * * NORMAL - * * 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, a CONST or a number. - */ - setBlendMode(value: string | Phaser.BlendModes | number): this; - - /** - * 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; - - /** - * 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; - - /** - * Sets the display size of this Game Object. - * - * Calling this will adjust the scale. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setDisplaySize(width: number, height: number): this; - - /** - * A boolean flag indicating if this Game Object is being cropped or not. - * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. - * Equally, calling `setCrop` with no arguments will reset the crop and disable it. - */ - isCropped: boolean; - - /** - * Applies a crop to a texture based Game Object, such as a Sprite or Image. - * - * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. - * - * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just - * changes what is shown when rendered. - * - * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. - * - * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left - * half of it, you could call `setCrop(0, 0, 400, 600)`. - * - * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop - * an area of 200x100 when applied to a Game Object that had a scale factor of 2. - * - * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. - * - * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. - * - * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow - * the renderer to skip several internal calculations. - * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. - * @param y The y coordinate to start the crop from. - * @param width The width of the crop rectangle in pixels. - * @param height The height of the crop rectangle in pixels. - */ - setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; - - /** - * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. - * - * 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. Ensure this value is only ever a number data-type. - */ - setDepth(value: number): this; - - /** - * The horizontally flipped state of the Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - */ - flipX: boolean; - - /** - * The vertically flipped state of the Game Object. - * - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipX(value: boolean): this; - - /** - * Sets the vertical flipped state of this Game Object. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipY(value: boolean): this; - - /** - * Sets the horizontal and vertical flipped state of this Game Object. - * - * A Game Object that is flipped will render inversed on the flipped axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlip(x: boolean, y: boolean): this; - - /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. - */ - resetFlip(): this; - - /** - * The amount of extra padding to be applied to this Game Object - * when it is being rendered by a SpriteFX Pipeline. - * - * Lots of FX require additional spacing added to the texture the - * Game Object uses, for example a glow or shadow effect, and this - * method allows you to control how much extra padding is included - * in addition to the texture size. - */ - fxPadding: number; - - /** - * Sets the amount of extra padding to be applied to this Game Object - * when it is being rendered by a SpriteFX Pipeline. - * - * Lots of FX require additional spacing added to the texture the - * Game Object uses, for example a glow or shadow effect, and this - * method allows you to control how much extra padding is included - * in addition to the texture size. - * @param padding The amount of padding to add to the texture. Default 0. - */ - setFXPadding(padding?: number): this; - - /** - * This callback is invoked when this Game Object is copied by a SpriteFX Pipeline. - * - * This happens when the pipeline uses its `copySprite` method. - * - * It's invoked prior to the copy, allowing you to set shader uniforms, etc on the pipeline. - * @param pipeline The SpriteFX Pipeline that invoked this callback. - */ - onFXCopy(pipeline: Phaser.Renderer.WebGL.Pipelines.SpriteFXPipeline): void; - - /** - * This callback is invoked when this Game Object is rendered by a SpriteFX Pipeline. - * - * This happens when the pipeline uses its `drawSprite` method. - * - * It's invoked prior to the draw, allowing you to set shader uniforms, etc on the pipeline. - * @param pipeline The SpriteFX Pipeline that invoked this callback. - */ - onFX(pipeline: Phaser.Renderer.WebGL.Pipelines.SpriteFXPipeline): void; - - /** - * 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 texture-based 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, or any kind of Shape Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): 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. - */ - postPipelines: 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 set 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 tint value being applied to the top-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintTopLeft: number; - - /** - * The tint value being applied to the top-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintTopRight: number; - - /** - * The tint value being applied to the bottom-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintBottomLeft: number; - - /** - * The tint value being applied to the bottom-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintBottomRight: number; - - /** - * The tint fill mode. - * - * `false` = An additive tint (the default), where vertices colors are blended with the texture. - * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. - */ - tintFill: boolean; - - /** - * Clears all tint values associated with this Game Object. - * - * Immediately sets the color values back to 0xffffff and the tint type to 'additive', - * which results in no visible change to the texture. - */ - clearTint(): this; - - /** - * Sets an additive tint on this Game Object. - * - * The tint works by taking the pixel color values from the Game Objects texture, and then - * multiplying it by the color value of the tint. You can provide either one color value, - * in which case the whole Game Object will be tinted in that color. Or you can provide a color - * per corner. The colors are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. - * - * To remove a tint call `clearTint`. - * - * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. - * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. - */ - setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; - - /** - * Sets a fill-based tint on this Game Object. - * - * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture - * with those in the tint. You can use this for effects such as making a player flash 'white' - * if hit by something. You can provide either one color value, in which case the whole - * Game Object will be rendered in that color. Or you can provide a color per corner. The colors - * are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. - * - * To remove a tint call `clearTint`. - * - * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. - */ - setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; - - /** - * The tint value being applied to the whole of the Game Object. - * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value. - */ - tint: number; - - /** - * Does this Game Object have a tint applied? - * - * It checks to see if the 4 tint properties are set to the value 0xffffff - * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. - */ - readonly isTinted: boolean; - - /** - * A property indicating that a Game Object has this component. - */ - readonly hasTransformComponent: boolean; - - /** - * 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; - - } - namespace Particles { /** * A Particle Emitter property. @@ -25981,7 +24958,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -25995,9 +24971,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The Mask this Game Object is using during render. @@ -26039,7 +25015,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -26336,7 +25312,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -26931,7 +25907,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -26946,7 +25921,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -26955,7 +25930,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -26969,9 +25943,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -27225,7 +26199,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -27614,19 +26588,17 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. + * The Frame has to belong to the current Texture being used. * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * It can be either a string or an index. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param frame The name or index of the frame within the Texture. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -28088,7 +27060,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -28103,7 +27074,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -28112,7 +27083,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -28126,9 +27096,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -28275,7 +27245,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -28709,17 +27679,6 @@ declare namespace Phaser { */ textureManager: Phaser.Textures.TextureManager; - /** - * Internal Image Game Object used as a Stamp within this Render Texture. - */ - stamp: Phaser.GameObjects.Image; - - /** - * This flag is set to 'true' during `beginDraw` and reset to 'false` in `endDraw`, - * allowing you to determine if this Render Texture is batch drawing, or not. - */ - readonly isDrawing: boolean; - /** * The tint of the Render Texture when rendered. */ @@ -28793,7 +27752,7 @@ declare namespace Phaser { /** * If you are planning on using this Render Texture as a base texture for Sprite * Game Objects, then you should call this method with a value of `true` before - * drawing anything to it, otherwise you will get inverted frames in WebGL. + * calling drawing anything to it, otherwise you will get inverted frames in WebGL. * @param value Is this Render Target being used as a Sprite Texture, or not? */ setIsSpriteTexture(value: boolean): this; @@ -29005,32 +27964,22 @@ declare namespace Phaser { drawFrame(key: string, frame?: string | number, x?: number, y?: number, alpha?: number, tint?: number): this; /** - * Resets the internal Stamp object, ready for drawing. - * @param alpha The alpha to use. Default 1. - * @param tint WebGL only. The tint color to use. Default 0xffffff. - */ - resetStamp(alpha?: number, tint?: number): Phaser.GameObjects.Image; - - /** - * Takes the given Texture Frame and draws it to this Render Texture as a fill pattern, - * i.e. in a grid-layout based on the frame dimensions. + * Takes the given Texture Frame and draws it to this Render Texture + * as a fill pattern, i.e. in a grid-layout based on the frame dimensions. * * Textures are referenced by their string-based keys, as stored in the Texture Manager. * * ```javascript * var rt = this.add.renderTexture(0, 0, 800, 600); - * - * rt.repeat(key, frame); + * rt.fillFrame(key, frame); * ``` * - * You can optionally provide a position, width, height, alpha and tint value to apply to - * the frames before they are drawn. The position controls the top-left where the repeating - * fill will start from. The width and height control the size of the filled area. + * You can optionally provide a position, alpha and tint value to apply to the frames + * before they are drawn. The position controls the offset of the first frame to be drawn + * and can be negative if required. * - * The position can be negative if required, but the dimensions cannot. - * - * Calling this method will cause a batch flush by default. Use the `skipBatch` argument - * to disable this, if this call is part of a larger batch draw. + * Calling this method will cause a batch flush, so if you've got a stack of things to draw + * in a tight loop, try using the `draw` method instead. * * If you are planning on using this Render Texture as a base texture for Sprite * Game Objects, then you should set `RenderTexture.isSpriteTexture = true` before @@ -29039,13 +27988,10 @@ declare namespace Phaser { * @param frame The name or index of the frame within the Texture. Set to `null` to skip this argument if not required. * @param x The x position to start drawing the frames from (can be negative to offset). Default 0. * @param y The y position to start drawing the frames from (can be negative to offset). Default 0. - * @param width The width of the area to repeat the frame within. Defaults to the width of this Render Texture. - * @param height The height of the area to repeat the frame within. Defaults to the height of this Render Texture. - * @param alpha The alpha to use. Defaults to 1, no alpha. Default 1. - * @param tint WebGL only. The tint color to use. Leave as undefined, or 0xffffff to have no tint. Default 0xffffff. - * @param skipBatch Skip beginning and ending a batch with this call. Use if this is part of a bigger batched draw. Default false. + * @param alpha The alpha to use. If not specified it uses the `globalAlpha` property. + * @param tint WebGL only. The tint color to use. If not specified it uses the `globalTint` property. */ - repeat(key: string, frame?: string | number, x?: number, y?: number, width?: number, height?: number, alpha?: number, tint?: number, skipBatch?: boolean): this; + fillFrame(key: string, frame?: string | number, x?: number, y?: number, alpha?: number, tint?: number): this; /** * Use this method if you need to batch draw a large number of Game Objects to @@ -29053,11 +27999,9 @@ declare namespace Phaser { * * This method starts the beginning of a batched draw. * - * Batch drawing is faster than calling `draw`, but you must be very careful to manage the - * flow of code and remember to call `endDraw()` when you're finished. - * - * If you don't need to draw large numbers of objects it's much safer and easier - * to use the `draw` method instead. + * It is faster than calling `draw`, but you must be very careful to manage the + * flow of code and remember to call `endDraw()`. If you don't need to draw large + * numbers of objects it's much safer and easier to use the `draw` method instead. * * The flow should be: * @@ -29076,10 +28020,7 @@ declare namespace Phaser { * * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you * have started a batch. Also, be very careful not to destroy this Render Texture while the - * batch is still open. - * - * You can use the `RenderTexture.isDrawing` boolean property to tell if a batch is - * currently open, or not. + * batch is still open, or call `beginDraw` again. */ beginDraw(): this; @@ -29212,13 +28153,11 @@ declare namespace Phaser { /** * Use this method to finish batch drawing to this Render Texture. * - * Calling this method without first calling `beginDraw` will have no effect. + * Never call this method without first calling `beginDraw`. * - * Batch drawing is faster than calling `draw`, but you must be very careful to manage the - * flow of code and remember to call `endDraw()` when you're finished. - * - * If you don't need to draw large numbers of objects it's much safer and easier - * to use the `draw` method instead. + * It is faster than calling `draw`, but you must be very careful to manage the + * flow of code and remember to call `endDraw()`. If you don't need to draw large + * numbers of objects it's much safer and easier to use the `draw` method instead. * * The flow should be: * @@ -29237,10 +28176,7 @@ declare namespace Phaser { * * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you * have started a batch. Also, be very careful not to destroy this Render Texture while the - * batch is still open. - * - * You can use the `RenderTexture.isDrawing` boolean property to tell if a batch is - * currently open, or not. + * batch is still open, or call `beginDraw` again. * @param erase Draws all objects in this batch using a blend mode of ERASE. This has the effect of erasing any filled pixels in the objects being drawn. Default false. */ endDraw(erase?: boolean): this; @@ -29362,7 +28298,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -29377,7 +28312,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -29386,7 +28321,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -29400,9 +28334,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The native (un-scaled) width of this Game Object. @@ -29737,7 +28671,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -30666,7 +29600,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -30681,7 +29614,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -30690,7 +29623,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -30704,9 +29636,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -30821,7 +29753,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -31057,19 +29989,17 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. + * The Frame has to belong to the current Texture being used. * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * It can be either a string or an index. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param frame The name or index of the frame within the Texture. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; /** * A property indicating that a Game Object has this component. @@ -31888,7 +30818,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -32220,6 +31150,830 @@ 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. Ensure this value is only ever set to a number data-type. + * + * 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. Ensure this value is only ever a number data-type. + */ + 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, or any kind of Shape Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): 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. + */ + postPipelines: 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 set 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; + + /** + * A property indicating that a Game Object has this component. + */ + readonly hasTransformComponent: boolean; + + /** + * 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 @@ -32337,7 +32091,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -32352,7 +32105,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -32361,7 +32114,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -32375,9 +32127,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -32524,7 +32276,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -33047,7 +32799,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -33062,7 +32813,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -33071,7 +32822,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -33085,9 +32835,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -33234,7 +32984,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -33767,7 +33517,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -33782,7 +33531,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -33791,7 +33540,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -33805,9 +33553,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -33954,7 +33702,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -34557,7 +34305,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -34572,7 +34319,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -34581,7 +34328,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -34595,9 +34341,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -34744,7 +34490,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -35314,7 +35060,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -35329,7 +35074,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -35338,7 +35083,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -35352,9 +35096,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -35501,7 +35245,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -36085,7 +35829,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -36100,7 +35843,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -36109,7 +35852,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -36123,9 +35865,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -36272,7 +36014,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -36812,7 +36554,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -36827,7 +36568,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -36836,7 +36577,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -36850,9 +36590,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -36999,7 +36739,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -37539,7 +37279,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -37554,7 +37293,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -37563,7 +37302,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -37577,9 +37315,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -37726,7 +37464,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -38240,7 +37978,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -38255,7 +37992,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -38264,7 +38001,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -38278,9 +38014,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -38427,833 +38163,7 @@ declare namespace Phaser { * * 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 texture-based 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, or any kind of Shape Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): 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. - */ - postPipelines: 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 set 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; - - /** - * A property indicating that a Game Object has this component. - */ - readonly hasTransformComponent: boolean; - - /** - * 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 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: - * - * * NORMAL - * * 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 | 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: - * - * * NORMAL - * * 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, a CONST or a number. - */ - setBlendMode(value: string | Phaser.BlendModes | number): this; - - /** - * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. - * - * 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. Ensure this value is only ever a number data-type. - */ - 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 texture-based Game Object. + * 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; @@ -39800,7 +38710,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -39815,7 +38724,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -39824,7 +38733,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -39838,9 +38746,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -39987,7 +38895,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -40508,7 +39416,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -40523,7 +39430,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -40532,7 +39439,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -40546,9 +39452,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -40695,7 +39601,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -41468,7 +40374,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -41483,7 +40388,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -41492,7 +40397,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -41506,9 +40410,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -41762,7 +40666,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -42151,19 +41055,17 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. + * The Frame has to belong to the current Texture being used. * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * It can be either a string or an index. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param frame The name or index of the frame within the Texture. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -42949,7 +41851,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -42964,7 +41865,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -42973,7 +41874,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -42987,9 +41887,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The displayed width of this Game Object. @@ -43331,7 +42231,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -44489,7 +43389,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -44504,7 +43403,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -44513,7 +43412,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -44527,9 +43425,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The native (un-scaled) width of this Game Object. @@ -44879,7 +43777,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -45435,55 +44333,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. * @@ -46062,7 +44911,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -46077,7 +44925,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -46086,7 +44934,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -46100,9 +44947,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -46347,7 +45194,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -46736,19 +45583,17 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. + * The Frame has to belong to the current Texture being used. * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * It can be either a string or an index. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param frame The name or index of the frame within the Texture. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -50318,6 +49163,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 | null; + + /** + * A reference to the Mouse Manager class, if enabled via the `input.mouse` Game Config property. + */ + mouse: Phaser.Input.Mouse.MouseManager | null; + + /** + * 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 | null; + + /** + * 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 | null; + + /** + * 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): this; + + /** + * 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 | null; + + /** + * 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 | null; + + } + + 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 | WheelEvent; + + /** + * 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. */ @@ -50363,27 +50545,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. @@ -51192,380 +51353,6 @@ declare namespace Phaser { } - namespace Configs { - /** - * Tatar SNES USB Controller Gamepad Configuration. - * USB Gamepad (STANDARD GAMEPAD Vendor: 0079 Product: 0011) - */ - namespace SNES_USB { - /** - * D-Pad up - */ - const UP: number; - - /** - * D-Pad down - */ - const DOWN: number; - - /** - * D-Pad left - */ - const LEFT: number; - - /** - * D-Pad right - */ - const RIGHT: number; - - /** - * Select button - */ - const SELECT: number; - - /** - * Start button - */ - const START: number; - - /** - * B Button (Bottom) - */ - const B: number; - - /** - * A Button (Right) - */ - const A: number; - - /** - * Y Button (Left) - */ - const Y: number; - - /** - * X Button (Top) - */ - const X: number; - - /** - * Left bumper - */ - const LEFT_SHOULDER: number; - - /** - * Right bumper - */ - const RIGHT_SHOULDER: number; - - } - - /** - * PlayStation DualShock 4 Gamepad Configuration. - * Sony PlayStation DualShock 4 (v2) wireless controller - */ - namespace DUALSHOCK_4 { - /** - * D-Pad up - */ - const UP: number; - - /** - * D-Pad down - */ - const DOWN: number; - - /** - * D-Pad left - */ - const LEFT: number; - - /** - * D-Pad up - */ - const RIGHT: number; - - /** - * Share button - */ - const SHARE: number; - - /** - * Options button - */ - const OPTIONS: number; - - /** - * PlayStation logo button - */ - const PS: number; - - /** - * Touchpad click - */ - const TOUCHBAR: number; - - /** - * Cross button (Bottom) - */ - const X: number; - - /** - * Circle button (Right) - */ - const CIRCLE: number; - - /** - * Square button (Left) - */ - const SQUARE: number; - - /** - * Triangle button (Top) - */ - const TRIANGLE: number; - - /** - * Left bumper (L1) - */ - const L1: number; - - /** - * Right bumper (R1) - */ - const R1: number; - - /** - * Left trigger (L2) - */ - const L2: number; - - /** - * Right trigger (R2) - */ - const R2: number; - - /** - * Left stick click (L3) - */ - const L3: number; - - /** - * Right stick click (R3) - */ - const R3: number; - - /** - * Left stick horizontal - */ - const LEFT_STICK_H: number; - - /** - * Left stick vertical - */ - const LEFT_STICK_V: number; - - /** - * Right stick horizontal - */ - const RIGHT_STICK_H: number; - - /** - * Right stick vertical - */ - const RIGHT_STICK_V: number; - - } - - /** - * XBox 360 Gamepad Configuration. - */ - namespace XBOX_360 { - /** - * D-Pad up - */ - const UP: number; - - /** - * D-Pad down - */ - const DOWN: number; - - /** - * D-Pad left - */ - const LEFT: number; - - /** - * D-Pad right - */ - const RIGHT: number; - - /** - * XBox menu button - */ - const MENU: number; - - /** - * A button (Bottom) - */ - const A: number; - - /** - * B button (Right) - */ - const B: number; - - /** - * X button (Left) - */ - const X: number; - - /** - * Y button (Top) - */ - const Y: number; - - /** - * Left Bumper - */ - const LB: number; - - /** - * Right Bumper - */ - const RB: number; - - /** - * Left Trigger - */ - const LT: number; - - /** - * Right Trigger - */ - const RT: number; - - /** - * Back / Change View button - */ - const BACK: number; - - /** - * Start button - */ - const START: number; - - /** - * Left Stick press - */ - const LS: number; - - /** - * Right stick press - */ - const RS: number; - - /** - * Left Stick horizontal - */ - const LEFT_STICK_H: number; - - /** - * Left Stick vertical - */ - const LEFT_STICK_V: number; - - /** - * Right Stick horizontal - */ - const RIGHT_STICK_H: number; - - /** - * Right Stick vertical - */ - const RIGHT_STICK_V: number; - - } - - } - - 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - } - /** * A single Gamepad. * @@ -51937,1102 +51724,383 @@ 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 | null; - - /** - * A reference to the Mouse Manager class, if enabled via the `input.mouse` Game Config property. - */ - mouse: Phaser.Input.Mouse.MouseManager | null; - - /** - * 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 | null; - - /** - * 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 | null; - - /** - * 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 | null; - - /** - * 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): this; - - /** - * 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 | null; - - } - - 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); + namespace SNES_USB { + /** + * D-Pad up + */ + const UP: number; + + /** + * D-Pad down + */ + const DOWN: number; + + /** + * D-Pad left + */ + const LEFT: number; + + /** + * D-Pad right + */ + const RIGHT: number; + + /** + * Select button + */ + const SELECT: number; + + /** + * Start button + */ + const START: number; + + /** + * B Button (Bottom) + */ + const B: number; + + /** + * A Button (Right) + */ + const A: number; + + /** + * Y Button (Left) + */ + const Y: number; + + /** + * X Button (Top) + */ + const X: number; + + /** + * Left bumper + */ + const LEFT_SHOULDER: number; + + /** + * Right bumper + */ + const RIGHT_SHOULDER: number; + + } /** - * A reference to the Keyboard Manager + * PlayStation DualShock 4 Gamepad Configuration. + * Sony PlayStation DualShock 4 (v2) wireless controller */ - manager: Phaser.Input.Keyboard.KeyboardPlugin; + namespace DUALSHOCK_4 { + /** + * D-Pad up + */ + const UP: number; + + /** + * D-Pad down + */ + const DOWN: number; + + /** + * D-Pad left + */ + const LEFT: number; + + /** + * D-Pad up + */ + const RIGHT: number; + + /** + * Share button + */ + const SHARE: number; + + /** + * Options button + */ + const OPTIONS: number; + + /** + * PlayStation logo button + */ + const PS: number; + + /** + * Touchpad click + */ + const TOUCHBAR: number; + + /** + * Cross button (Bottom) + */ + const X: number; + + /** + * Circle button (Right) + */ + const CIRCLE: number; + + /** + * Square button (Left) + */ + const SQUARE: number; + + /** + * Triangle button (Top) + */ + const TRIANGLE: number; + + /** + * Left bumper (L1) + */ + const L1: number; + + /** + * Right bumper (R1) + */ + const R1: number; + + /** + * Left trigger (L2) + */ + const L2: number; + + /** + * Right trigger (R2) + */ + const R2: number; + + /** + * Left stick click (L3) + */ + const L3: number; + + /** + * Right stick click (R3) + */ + const R3: number; + + /** + * Left stick horizontal + */ + const LEFT_STICK_H: number; + + /** + * Left stick vertical + */ + const LEFT_STICK_V: number; + + /** + * Right stick horizontal + */ + const RIGHT_STICK_H: number; + + /** + * Right stick vertical + */ + const RIGHT_STICK_V: number; + + } /** - * A flag that controls if this Key Combo is actively processing keys or not. + * XBox 360 Gamepad Configuration. */ - enabled: boolean; + namespace XBOX_360 { + /** + * D-Pad up + */ + const UP: number; - /** - * An array of the keycodes that comprise this combo. - */ - keyCodes: any[]; + /** + * D-Pad down + */ + const DOWN: number; - /** - * The current keyCode the combo is waiting for. - */ - current: number; + /** + * D-Pad left + */ + const LEFT: number; - /** - * The current index of the key being waited for in the 'keys' string. - */ - index: number; + /** + * D-Pad right + */ + const RIGHT: number; - /** - * The length of this combo (in keycodes) - */ - size: number; + /** + * XBox menu button + */ + const MENU: number; - /** - * The time the previous key in the combo was matched. - */ - timeLastMatched: number; + /** + * A button (Bottom) + */ + const A: number; - /** - * Has this Key Combo been matched yet? - */ - matched: boolean; + /** + * B button (Right) + */ + const B: number; - /** - * The time the entire combo was matched. - */ - timeMatched: number; + /** + * X button (Left) + */ + const X: number; - /** - * If they press the wrong key do we reset the combo? - */ - resetOnWrongKey: boolean; + /** + * Y button (Top) + */ + const Y: number; - /** - * The max delay in ms between each key press. Above this the combo is reset. 0 means disabled. - */ - maxKeyDelay: number; + /** + * Left Bumper + */ + const LB: number; - /** - * If previously matched and they press the first key of the combo again, will it reset? - */ - resetOnMatch: boolean; + /** + * Right Bumper + */ + const RB: number; - /** - * If the combo matches, will it delete itself? - */ - deleteOnMatch: boolean; + /** + * Left Trigger + */ + const LT: number; - /** - * How far complete is this combo? A value between 0 and 1. - */ - readonly progress: number; + /** + * Right Trigger + */ + const RT: number; - /** - * Destroys this Key Combo and all of its references. - */ - destroy(): void; + /** + * Back / Change View button + */ + const BACK: number; + + /** + * Start button + */ + const START: number; + + /** + * Left Stick press + */ + const LS: number; + + /** + * Right stick press + */ + const RS: number; + + /** + * Left Stick horizontal + */ + const LEFT_STICK_H: number; + + /** + * Left Stick vertical + */ + const LEFT_STICK_V: number; + + /** + * Right Stick horizontal + */ + const RIGHT_STICK_H: number; + + /** + * Right Stick vertical + */ + const RIGHT_STICK_V: number; + + } } 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: string; + 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: string; + 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: string; + 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: string; + 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: string; + 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: string; - - /** - * 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: string; + const GAMEPAD_BUTTON_UP: any; } + } + + namespace Keyboard { /** * The Keyboard Manager is a helper class that belongs to the global Input Manager. * @@ -53509,6 +52577,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. @@ -54375,468 +53682,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 | WheelEvent; - - /** - * 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. @@ -54961,223 +53806,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; - - /** - * File is pending being destroyed. - */ - var FILE_PENDING_DESTROY: 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: string; - - /** - * 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: string; - - /** - * 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)`. - * - * Make sure you remove this listener when you have finished, or it will continue to fire if the Scene reloads. - * - * 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: string; - - /** - * 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 - * }); - * ``` - * - * Make sure you remove your listeners when you have finished, or they will continue to fire if the Scene reloads. - * - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - } - /** * 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. @@ -55385,961 +54013,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?: Phaser.Types.Loader.FileTypes.AudioFileURLConfig, 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 Compressed Texture File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#texture method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#texture. - */ - class CompressedTextureFile 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. - * @param entry The compressed texture file entry to load. - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string, entry: Phaser.Types.Loader.FileTypes.CompressedTextureFileEntry, xhrSettings?: 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; - - /** - * Adds all of the multi-file entties to their target caches upon successful loading and processing. - */ - addMultiToCache(): 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 type The script type. Should be either 'script' for classic JavaScript, or 'module' if the file contains an exported module. Default 'script'. - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.ScriptFileConfig, url?: string, type?: 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?: Phaser.Types.Loader.FileTypes.VideoFileURLConfig, 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. @@ -56405,6 +54078,348 @@ 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; + + /** + * Optional load type for image files. `XHR` is the default. Set to `HTMLImageElement` to load images using the Image tag instead. + */ + imageLoadType: string; + + /** + * An array of all schemes that the Loader considers as being 'local'. + * + * This is populated by the `Phaser.Core.Config#loaderLocalScheme` game configuration setting and defaults to + * `[ 'file://', 'capacitor://' ]`. Additional local schemes can be added to this array as needed. + */ + localSchemes: 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. * @@ -57129,6 +55144,57 @@ declare namespace Phaser { */ bitmapFont(key: string | Phaser.Types.Loader.FileTypes.BitmapFontFileConfig | Phaser.Types.Loader.FileTypes.BitmapFontFileConfig[], textureURL?: string | string[], fontDataURL?: string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, fontDataXhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; + /** + * Adds a CSS file, or array of CSS files, to the current load queue. + * + * 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.css('headers', 'styles/headers.css'); + * } + * ``` + * + * 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 and not already in-use by another file in the Loader. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.css({ + * key: 'headers', + * url: 'styles/headers.css' + * }); + * ``` + * + * See the documentation for `Phaser.Types.Loader.FileTypes.CSSFileConfig` for more details. + * + * Once the file has finished loading it will automatically be converted into a style DOM element + * via `document.createElement('style')`. It will have its `defer` property set to false and then the + * resulting element will be appended to `document.head`. The CSS styles are then applied to the current document. + * + * 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.css". It will always add `.css` 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. + * + * Note: The ability to load this type of file will only be available if the CSS 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 `.css`, i.e. if `key` was "alien" then the URL will be "alien.css". + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + css(key: string | Phaser.Types.Loader.FileTypes.CSSFileConfig | Phaser.Types.Loader.FileTypes.CSSFileConfig[], url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; + /** * Adds a Compressed Texture file to the current load queue. This feature is WebGL only. * @@ -57263,57 +55329,6 @@ declare namespace Phaser { */ texture(key: string | Phaser.Types.Loader.FileTypes.CompressedTextureFileConfig | Phaser.Types.Loader.FileTypes.CompressedTextureFileConfig[], url?: Phaser.Types.Loader.FileTypes.CompressedTextureFileConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; - /** - * Adds a CSS file, or array of CSS files, to the current load queue. - * - * 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.css('headers', 'styles/headers.css'); - * } - * ``` - * - * 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 and not already in-use by another file in the Loader. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.css({ - * key: 'headers', - * url: 'styles/headers.css' - * }); - * ``` - * - * See the documentation for `Phaser.Types.Loader.FileTypes.CSSFileConfig` for more details. - * - * Once the file has finished loading it will automatically be converted into a style DOM element - * via `document.createElement('style')`. It will have its `defer` property set to false and then the - * resulting element will be appended to `document.head`. The CSS styles are then applied to the current document. - * - * 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.css". It will always add `.css` 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. - * - * Note: The ability to load this type of file will only be available if the CSS 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 `.css`, i.e. if `key` was "alien" then the URL will be "alien.css". - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - css(key: string | Phaser.Types.Loader.FileTypes.CSSFileConfig | Phaser.Types.Loader.FileTypes.CSSFileConfig[], url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; - /** * Adds a GLSL file, or array of GLSL files, to the current load queue. * In Phaser 3 GLSL files are just plain Text files at the current moment in time. @@ -58083,6 +56098,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. * @@ -58393,118 +56520,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. * @@ -58974,348 +56989,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; - - /** - * Optional load type for image files. `XHR` is the default. Set to `HTMLImageElement` to load images using the Image tag instead. - */ - imageLoadType: string; - - /** - * An array of all schemes that the Loader considers as being 'local'. - * - * This is populated by the `Phaser.Core.Config#loaderLocalScheme` game configuration setting and defaults to - * `[ 'file://', 'capacitor://' ]`. Additional local schemes can be added to this array as needed. - */ - localSchemes: 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; - } /** @@ -59465,129 +57138,1181 @@ 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; + + /** + * File is pending being destroyed. + */ + var FILE_PENDING_DESTROY: 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)`. + * + * Make sure you remove this listener when you have finished, or it will continue to fire if the Scene reloads. + * + * 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 + * }); + * ``` + * + * Make sure you remove your listeners when you have finished, or they will continue to fire if the Scene reloads. + * + * 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?: Phaser.Types.Loader.FileTypes.AudioFileURLConfig, 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 Compressed Texture File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#texture method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#texture. + */ + class CompressedTextureFile 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. + * @param entry The compressed texture file entry to load. + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string, entry: Phaser.Types.Loader.FileTypes.CompressedTextureFileEntry, xhrSettings?: 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; + + /** + * Adds all of the multi-file entties to their target caches upon successful loading and processing. + */ + addMultiToCache(): 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 type The script type. Should be either 'script' for classic JavaScript, or 'module' if the file contains an exported module. Default 'script'. + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.ScriptFileConfig, url?: string, type?: 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?: Phaser.Types.Loader.FileTypes.VideoFileURLConfig, 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. @@ -59636,49 +58361,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. @@ -59692,313 +58374,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 { /** * @@ -60041,53 +58416,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. @@ -60095,67 +58423,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. @@ -60654,29 +58921,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. */ @@ -60882,149 +59126,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. * @@ -61141,6 +59242,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`. * @@ -61155,56 +59268,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. * @@ -62044,6 +60107,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; + + } + } /** @@ -62738,7 +61583,7 @@ declare namespace Phaser { /** * A scene or scenes to add to the game. If several are given, the first is started; the remainder are started only if they have `{ active: true }`. See the `sceneConfig` argument in `Phaser.Scenes.SceneManager#add`. */ - scene?: Phaser.Types.Scenes.SceneType | Phaser.Types.Scenes.SceneType[]; + scene?: Phaser.Scene | Phaser.Scene[] | Phaser.Types.Scenes.SettingsConfig | Phaser.Types.Scenes.SettingsConfig[] | Phaser.Types.Scenes.CreateSceneFromObjectConfig | Phaser.Types.Scenes.CreateSceneFromObjectConfig[] | Function | Function[]; /** * Seed for the random number generator. */ @@ -65716,8 +64561,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? @@ -65737,6 +64580,8 @@ declare namespace Phaser { deleteOnMatch?: boolean; }; + type KeyboardKeydownCallback = (event: KeyboardEvent)=>void; + } /** @@ -66114,6 +64959,25 @@ declare namespace Phaser { fontDataXhrSettings?: Phaser.Types.Loader.XHRSettingsObject; }; + type CSSFileConfig = { + /** + * The key of the file. Must be unique within the Loader. + */ + 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; + }; + type CompressedTextureFileEntry = { /** * The texture compression base format that the browser must support in order to load this file. Can be any of: 'ETC', 'ETC1', 'ATC', 'ASTC', 'BPTC', 'RGTC', 'PVRTC', 'S3TC', 'S3TCSRGB' or the fallback format of 'IMG'. @@ -66188,25 +65052,6 @@ declare namespace Phaser { IMG?: Phaser.Types.Loader.FileTypes.CompressedTextureFileEntry | string; }; - type CSSFileConfig = { - /** - * The key of the file. Must be unique within the Loader. - */ - 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; - }; - type GLSLFileConfig = { /** * The key of the file. Must be unique within both the Loader and the Text Cache. @@ -66511,6 +65356,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. @@ -66607,44 +65490,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. @@ -68725,8 +67570,6 @@ declare namespace Phaser { data?: any; }; - type SceneType = Phaser.Scene | Phaser.Types.Scenes.SettingsConfig | Phaser.Types.Scenes.CreateSceneFromObjectConfig | Function; - type SceneUpdateCallback = (this: Phaser.Scene, time: number, delta: number)=>void; type SettingsConfig = { @@ -69088,56 +67931,6 @@ declare namespace Phaser { spacing?: number; }; - /** - * An object containing the position and color data for a single pixel in a CanvasTexture. - */ - type StampConfig = { - /** - * The alpha value used by the stamp. - */ - alpha?: number; - /** - * The tint color value used by the stamp. WebGL only. - */ - tint?: number; - /** - * The angle of the stamp in degrees. Rotation takes place around its origin. - */ - angle?: number; - /** - * The rotation of the stamp in radians. Rotation takes place around its origin. - */ - rotation?: number; - /** - * Sets both the horizontal and vertical scale of the stamp with a single value. - */ - scale?: number; - /** - * Set the horizontal scale of the stamp. Overrides the scale property, if provided. - */ - scaleX?: number; - /** - * Set the vertical scale of the stamp. Overrides the scale property, if provided. - */ - scaleY?: number; - /** - * The horizontal origin of the stamp. 0 is the left, 0.5 is the center and 1 is the right. - */ - originX?: number; - /** - * The vertical origin of the stamp. 0 is the top, 0.5 is the center and 1 is the bottom. - */ - originY?: number; - /** - * The blend mode used when drawing the stamp. Defaults to 0 (normal). - */ - blendMode?: string | Phaser.BlendModes | number; - /** - * Erase this stamp from the texture? - */ - erase?: boolean; - }; - } namespace Tilemaps { @@ -70041,6 +68834,8 @@ declare namespace Phaser { interpolation?: string | Function; }; + type TweenCallbackTypes = 'onActive' | 'onComplete' | 'onLoop' | 'onPause' | 'onRepeat' | 'onResume' | 'onStart' | 'onStop' | 'onUpdate' | 'onYoyo'; + type TweenCallbacks = { /** * A function to call when the tween becomes active within the Tween Manager. @@ -70084,8 +68879,6 @@ declare namespace Phaser { onYoyo?: Phaser.Types.Tweens.TweenOnYoyoCallback; }; - type TweenCallbackTypes = 'onActive' | 'onComplete' | 'onLoop' | 'onPause' | 'onRepeat' | 'onResume' | 'onStart' | 'onStop' | 'onUpdate' | 'onYoyo'; - type TweenChainBuilderConfig = { /** * The object, or an array of objects, to run the tween on. @@ -70575,7 +69368,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -70590,7 +69382,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -70599,7 +69391,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -70613,9 +69404,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -70869,7 +69660,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -71258,19 +70049,17 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. + * The Frame has to belong to the current Texture being used. * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * It can be either a string or an index. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param frame The name or index of the frame within the Texture. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -72291,7 +71080,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -72306,7 +71094,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -72315,7 +71103,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -72329,9 +71116,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -72585,7 +71372,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -72974,19 +71761,17 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. + * The Frame has to belong to the current Texture being used. * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * It can be either a string or an index. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param frame The name or index of the frame within the Texture. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -74598,562 +73383,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. - * @param onWorldBounds If given this replaces the Body's `onWorldBounds` value. - */ - setCollideWorldBounds(value?: boolean, bounceX?: number, bounceY?: number, onWorldBounds?: boolean): 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - } - /** * 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. @@ -75868,73 +74097,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. * @@ -76523,6 +74685,629 @@ 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. + * @param onWorldBounds If given this replaces the Body's `onWorldBounds` value. + */ + setCollideWorldBounds(value?: boolean, bounceX?: number, bounceY?: number, onWorldBounds?: boolean): 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 { @@ -76661,743 +75446,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: string; - - 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: string; - - 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: string; - - 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: string; - - 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: string; - - 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: string; - - 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: string; - - 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: string; - - 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - 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: string; - - 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: string; - - } - /** * 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. @@ -77972,7 +76023,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -77987,7 +76037,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -77996,7 +76046,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -78010,9 +76059,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -78266,7 +76315,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -78655,19 +76704,17 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. + * The Frame has to belong to the current Texture being used. * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * It can be either a string or an index. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param frame The name or index of the frame within the Texture. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -79954,7 +78001,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -79969,7 +78015,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -79978,7 +78024,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -79992,9 +78037,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -80248,7 +78293,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -80637,19 +78682,17 @@ declare namespace Phaser { /** * Sets the frame this Game Object will use to render with. * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. + * The Frame has to belong to the current Texture being used. * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * It can be either a string or an index. * * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param frame The name or index of the frame within the Texture. * @param updateSize Should this call adjust the size of the Game Object? Default true. * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + setFrame(frame: string | number, updateSize?: boolean, updateOrigin?: boolean): this; /** * The tint value being applied to the top-left vertice of the Game Object. @@ -82275,6 +80318,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; + + } + } } @@ -82977,6 +81754,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 { /** @@ -83256,7 +82051,7 @@ declare namespace Phaser { * This event is dispatched by the Renderer when all rendering, for all cameras in all Scenes, * has completed, but before any pending snap shots have been taken. */ - const POST_RENDER: string; + const POST_RENDER: any; /** * The Pre-Render Event. @@ -83265,7 +82060,7 @@ declare namespace Phaser { * process, after the context has been cleared, the scissors enabled (WebGL only) and everything has been * reset ready for the render. */ - const PRE_RENDER: string; + const PRE_RENDER: any; /** * The Render Event. @@ -83274,7 +82069,7 @@ declare namespace Phaser { * * It is dispatched before any of the children in the Scene have been rendered. */ - const RENDER: string; + const RENDER: any; /** * The Renderer Resize Event. @@ -83282,7 +82077,7 @@ declare namespace Phaser { * This event is dispatched by the Phaser Renderer when it is resized, usually as a result * of the Scale Manager resizing. */ - const RESIZE: string; + const RESIZE: any; } @@ -83310,41 +82105,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. @@ -83851,1501 +82611,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 The BitmapMask instance that called beginMask. - * @param maskedObject GameObject masked by the mask GameObject. - * @param camera The camera rendering the current mask. - */ - beginMask(mask: Phaser.Display.Masks.BitmapMask, 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 The BitmapMask instance that called endMask. - * @param camera The Camera to render to. - * @param renderTarget Optional WebGL RenderTarget. - */ - endMask(mask: Phaser.Display.Masks.BitmapMask, camera: Phaser.Cameras.Scene2D.Camera, renderTarget?: Phaser.Renderer.WebGL.RenderTarget): 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 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; - - /** - * A persistent calculation vector used when processing the lights. - */ - tempVec2: Phaser.Math.Vec2; - - /** - * 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 should use the string - * declaration `%count%` in your fragment shader source, which is used to set the number of - * `sampler2Ds` available. Also add `%getSampler%` so Phaser can inject the getSampler glsl function. - * This function can be used to get the pixel vec4 from the texture: - * - * `vec4 texture = getSampler(int(outTexId), outTexCoord);` - * - * This pipeline will automatically inject the getSampler function for you, should the value 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); - - /** - * A temporary Transform Matrix, re-used internally during batching by the - * Shape Game Objects. - */ - calcMatrix: Phaser.GameObjects.Components.TransformMatrix; - - /** - * 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; - - /** - * 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; - - } - - /** - * 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 SpriteFX Pipeline is a special kind of pipeline designed specifically for applying - * special effects to Sprites. Where-as the Post FX Pipeline applies an effect _after_ the - * object has been rendered, the Sprite FX Pipeline allows you to control the rendering of - * the object itself - passing it off to its own texture where multi-buffer compositing - * can take place. - * - * You can only use the SpriteFX Pipeline on the following types of Game Objects, or those - * that extend from them: - * - * Sprite - * Image - * Text - * TileSprite - * RenderTexture - * - * // TODO - Explain about the fbos and functions - */ - class SpriteFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - - /** - * A reference to the Draw Sprite Shader belonging to this Pipeline. - * - * This shader is used when the sprite is drawn to this fbo (or to the game if drawToFrame is false) - * - * This property is set during the `boot` method. - */ - drawSpriteShader: Phaser.Renderer.WebGL.WebGLShader; - - /** - * A reference to the Copy Shader belonging to this Pipeline. - * - * This shader is used when you call the `copySprite` method. - * - * This property is set during the `boot` method. - */ - copyShader: Phaser.Renderer.WebGL.WebGLShader; - - /** - * A reference to the Game Draw Shader belonging to this Pipeline. - * - * This shader draws the fbo to the game. - * - * This property is set during the `boot` method. - */ - gameShader: Phaser.Renderer.WebGL.WebGLShader; - - /** - * Raw byte buffer of vertices used specifically during the copySprite method. - */ - readonly quadVertexData: ArrayBuffer; - - /** - * The WebGLBuffer that holds the quadVertexData. - */ - readonly quadVertexBuffer: WebGLBuffer; - - /** - * Float32 view of the quad array buffer. - */ - quadVertexViewF32: Float32Array; - - /** - * The full-screen Render Target that the sprite is first drawn to. - */ - fsTarget: Phaser.Renderer.WebGL.RenderTarget; - - /** - * Handles the resizing of the quad vertex data. - * @param width The new width of the quad. - * @param height The new height of the quad. - */ - onResize(width: number, height: number): void; - - /** - * Takes a Sprite Game Object, or any object that extends it, and renders it via this pipeline. - * - * this method is a proxy for the MultiPipeline method of the same name. The actual rendering - * is redirected through to the `batchQuad` method in this pipeline. - * @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 the vertices data into the batch and flushes if full. - * - * Assumes 6 vertices in the following arrangement: - * - * ``` - * 0----3 - * |\ B| - * | \ | - * | \ | - * | A \| - * | \ - * 1----2 - * ``` - * - * Where x0 / y0 = 0, x1 / y1 = 1, x2 / y2 = 2 and x3 / y3 = 3 - * @param gameObject The Game Object, if any, drawing this quad. - * @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 u0 UV u0 value. - * @param v0 UV v0 value. - * @param u1 UV u1 value. - * @param v1 UV v1 value. - * @param tintTL The top-left tint color value. - * @param tintTR The top-right tint color value. - * @param tintBL The bottom-left tint color value. - * @param tintBR The bottom-right tint color value. - * @param tintEffect The tint effect for the shader to use. - * @param texture WebGLTexture that will be assigned to the current batch if a flush occurs. - */ - batchQuad(gameObject: Phaser.GameObjects.GameObject | null, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, u0: number, v0: number, u1: number, v1: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number | boolean, texture?: WebGLTexture): boolean; - - /** - * This callback is invoked when a sprite is drawn by this pipeline. - * - * It will fire after the shader has been set, but before the sprite has been drawn, - * so use it to set any additional uniforms you may need. - * - * Note: Manipulating the Sprite during this callback will _not_ change how it is drawn to the Render Target. - * @param gameObject The Sprite being drawn. - * @param target The Render Target the Sprite will be drawn to. - */ - onDrawSprite(gameObject: Phaser.GameObjects.Sprite, target: Phaser.Renderer.WebGL.RenderTarget): void; - - /** - * This callback is invoked when you call the `copySprite` method. - * - * It will fire after the shader has been set, but before the source target has been copied, - * so use it to set any additional uniforms you may need. - * - * Note: Manipulating the Sprite during this callback will _not_ change the Render Targets. - * @param source The source Render Target being copied from. - * @param target The target Render Target that will be copied to. - * @param gameObject The Sprite being copied. - */ - onCopySprite(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, gameObject: Phaser.GameObjects.Sprite): void; - - /** - * Copy the `source` Render Target to the `target` Render Target. - * - * No target 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. - * - * Calling this method will invoke the `onCopySprite` handler and will also call - * the `onFXCopy` callback on the Sprite. Both of these happen prior to the copy, allowing you - * to use them to set shader uniforms and other values. - * @param source The source Render Target being copied from. - * @param target The target Render Target that will be copied to. - * @param gameObject The Sprite being copied. - * @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. - * @param shader The shader to use to copy the target. Defaults to the `copyShader`. - */ - copySprite(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, gameObject: Phaser.GameObjects.Sprite, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean, shader?: Phaser.Renderer.WebGL.WebGLShader): 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; - - /** - * This method will copy the given Render Target to the game canvas using the `copyShader`. - * - * This applies the results of the copy shader during the draw. - * - * If you wish to copy the target without any effects see the `copyToGame` method instead. - * - * This method should be the final thing called in your pipeline. - * @param source The Render Target to draw to the game. - */ - drawToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; - - /** - * This method will copy the given Render Target to the game canvas using the `gameShader`. - * - * Unless you've changed it, the `gameShader` copies the target without modifying it, just - * ensuring it is placed in the correct location on the canvas. - * - * If you wish to draw the target with and apply the fragment shader at the same time, - * see the `drawToGame` method instead. - * - * This method should be the final thing called in your pipeline. - * @param source The Render Target to copy to the game. - */ - copyToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; - - /** - * This method is called by `drawToGame` and `copyToGame`. It takes the source Render Target - * and copies it back to the game canvas, or the next frame buffer in the stack, and should - * be considered the very last thing this pipeline does. - * - * You don't normally need to call this method, or override it, however it is left public - * should you wish to do so. - * - * Note that it does _not_ set a shader. You should do this yourself if invoking this. - * @param source The Render Target to draw to the game. - */ - bindAndDraw(source: Phaser.Renderer.WebGL.RenderTarget): void; - - /** - * This method is called every time the `batchSprite` method is called and is passed a - * reference to the current render target. - * - * If you override this method, then it should make sure it calls either the - * `drawToGame` or `copyToGame` methods as the final thing it does. However, you can do as - * much additional processing as you like prior to this. - * @param target The Render Target to draw to the game. - * @param swapTarget The Swap Render Target, useful for double-buffer effects. - * @param altSwapTarget The Swap Render Target, useful for double-buffer effects. - */ - onDraw(target: Phaser.Renderer.WebGL.RenderTarget, swapTarget?: Phaser.Renderer.WebGL.RenderTarget, altSwapTarget?: Phaser.Renderer.WebGL.RenderTarget): void; - - /** - * Set the UV values for the 6 vertices that make up the quad used by the copy shader. - * - * 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 copy shaders - * 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; - - /** - * Resets the quad vertice UV values to their default settings. - * - * The quad is used by the copy shader in this pipeline. - */ - resetUVs(): void; - - /** - * Destroys all shader instances, removes all object references and nulls all external references. - */ - destroy(): this; - - } - - /** - * 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. - * @param flipY Flip the UV on the Y axis before drawing? Default false. - */ - blitFrame(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean, flipY?: 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. * @@ -85516,8 +82781,6 @@ declare namespace Phaser { /** * Check to see how many texture units the GPU supports in a fragment shader * and if the value specific in the game config is allowed. - * - * This value is hard-clamped to 16 for performance reasons on Android devices. * @param gl The WebGLContext used to create the shaders. * @param maxTextures The Game Config maxTextures value. */ @@ -86834,20 +84097,6 @@ declare namespace Phaser { */ projectionHeight: number; - /** - * A RenderTarget used by the BitmapMask Pipeline. - * - * This is the source, i.e. the masked Game Object itself. - */ - maskSource: Phaser.Renderer.WebGL.RenderTarget; - - /** - * A RenderTarget used by the BitmapMask Pipeline. - * - * This is the target, i.e. the framebuffer the masked objects are drawn to. - */ - maskTarget: Phaser.Renderer.WebGL.RenderTarget; - /** * Creates a new WebGLRenderingContext and initializes all internal state. * @param config The configuration object for the renderer. @@ -87169,23 +84418,6 @@ declare namespace Phaser { */ createFramebuffer(width: number, height: number, renderTexture: WebGLTexture, addDepthStencilBuffer?: boolean): WebGLFramebuffer; - /** - * 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 The BitmapMask instance that called beginMask. - * @param camera The camera rendering the current mask. - */ - beginBitmapMask(mask: Phaser.Display.Masks.BitmapMask, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * 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 The BitmapMask instance that called beginMask. - * @param camera The camera rendering the current mask. - * @param bitmapMaskPipeline The BitmapMask Pipeline instance that is requesting the draw. - */ - drawBitmapMask(mask: Phaser.Display.Masks.BitmapMask, camera: Phaser.Cameras.Scene2D.Camera, bitmapMaskPipeline: Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline): void; - /** * Creates a WebGLProgram instance based on the given vertex and fragment shader source. * @@ -87959,205 +85191,1534 @@ 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 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 should use the string + * declaration `%count%` in your fragment shader source, which is used to set the number of + * `sampler2Ds` available. Also add `%getSampler%` so Phaser can inject the getSampler glsl function. + * This function can be used to get the pixel vec4 from the texture: + * + * `vec4 texture = getSampler(int(outTexId), outTexCoord);` + * + * This pipeline will automatically inject the getSampler function for you, should the value 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); + + /** + * A temporary Transform Matrix, re-used internally during batching by the + * Shape Game Objects. + */ + calcMatrix: Phaser.GameObjects.Components.TransformMatrix; + + /** + * 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; + + /** + * 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; + + } + + /** + * 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 SpriteFX Pipeline is a special kind of pipeline designed specifically for applying + * special effects to Sprites. Where-as the Post FX Pipeline applies an effect _after_ the + * object has been rendered, the Sprite FX Pipeline allows you to control the rendering of + * the object itself - passing it off to its own texture where multi-buffer compositing + * can take place. + * + * You can only use the SpriteFX Pipeline on the following types of Game Objects, or those + * that extend from them: + * + * Sprite + * Image + * Text + * TileSprite + * RenderTexture + * + * // TODO - Explain about the fbos and functions + */ + class SpriteFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + + /** + * A reference to the Draw Sprite Shader belonging to this Pipeline. + * + * This shader is used when the sprite is drawn to this fbo (or to the game if drawToFrame is false) + * + * This property is set during the `boot` method. + */ + drawSpriteShader: Phaser.Renderer.WebGL.WebGLShader; + + /** + * A reference to the Copy Shader belonging to this Pipeline. + * + * This shader is used when you call the `copySprite` method. + * + * This property is set during the `boot` method. + */ + copyShader: Phaser.Renderer.WebGL.WebGLShader; + + /** + * A reference to the Game Draw Shader belonging to this Pipeline. + * + * This shader draws the fbo to the game. + * + * This property is set during the `boot` method. + */ + gameShader: Phaser.Renderer.WebGL.WebGLShader; + + /** + * Raw byte buffer of vertices used specifically during the copySprite method. + */ + readonly quadVertexData: ArrayBuffer; + + /** + * The WebGLBuffer that holds the quadVertexData. + */ + readonly quadVertexBuffer: WebGLBuffer; + + /** + * Float32 view of the quad array buffer. + */ + quadVertexViewF32: Float32Array; + + /** + * The full-screen Render Target that the sprite is first drawn to. + */ + fsTarget: Phaser.Renderer.WebGL.RenderTarget; + + /** + * Handles the resizing of the quad vertex data. + * @param width The new width of the quad. + * @param height The new height of the quad. + */ + onResize(width: number, height: number): void; + + /** + * Takes a Sprite Game Object, or any object that extends it, and renders it via this pipeline. + * + * this method is a proxy for the MultiPipeline method of the same name. The actual rendering + * is redirected through to the `batchQuad` method in this pipeline. + * @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 the vertices data into the batch and flushes if full. + * + * Assumes 6 vertices in the following arrangement: + * + * ``` + * 0----3 + * |\ B| + * | \ | + * | \ | + * | A \| + * | \ + * 1----2 + * ``` + * + * Where x0 / y0 = 0, x1 / y1 = 1, x2 / y2 = 2 and x3 / y3 = 3 + * @param gameObject The Game Object, if any, drawing this quad. + * @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 u0 UV u0 value. + * @param v0 UV v0 value. + * @param u1 UV u1 value. + * @param v1 UV v1 value. + * @param tintTL The top-left tint color value. + * @param tintTR The top-right tint color value. + * @param tintBL The bottom-left tint color value. + * @param tintBR The bottom-right tint color value. + * @param tintEffect The tint effect for the shader to use. + * @param texture WebGLTexture that will be assigned to the current batch if a flush occurs. + */ + batchQuad(gameObject: Phaser.GameObjects.GameObject | null, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, u0: number, v0: number, u1: number, v1: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number | boolean, texture?: WebGLTexture): boolean; + + /** + * This callback is invoked when a sprite is drawn by this pipeline. + * + * It will fire after the shader has been set, but before the sprite has been drawn, + * so use it to set any additional uniforms you may need. + * + * Note: Manipulating the Sprite during this callback will _not_ change how it is drawn to the Render Target. + * @param gameObject The Sprite being drawn. + * @param target The Render Target the Sprite will be drawn to. + */ + onDrawSprite(gameObject: Phaser.GameObjects.Sprite, target: Phaser.Renderer.WebGL.RenderTarget): void; + + /** + * This callback is invoked when you call the `copySprite` method. + * + * It will fire after the shader has been set, but before the source target has been copied, + * so use it to set any additional uniforms you may need. + * + * Note: Manipulating the Sprite during this callback will _not_ change the Render Targets. + * @param source The source Render Target being copied from. + * @param target The target Render Target that will be copied to. + * @param gameObject The Sprite being copied. + */ + onCopySprite(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, gameObject: Phaser.GameObjects.Sprite): void; + + /** + * Copy the `source` Render Target to the `target` Render Target. + * + * No target 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. + * + * Calling this method will invoke the `onCopySprite` handler and will also call + * the `onFXCopy` callback on the Sprite. Both of these happen prior to the copy, allowing you + * to use them to set shader uniforms and other values. + * @param source The source Render Target being copied from. + * @param target The target Render Target that will be copied to. + * @param gameObject The Sprite being copied. + * @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. + * @param shader The shader to use to copy the target. Defaults to the `copyShader`. + */ + copySprite(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, gameObject: Phaser.GameObjects.Sprite, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean, shader?: Phaser.Renderer.WebGL.WebGLShader): 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; + + /** + * This method will copy the given Render Target to the game canvas using the `copyShader`. + * + * This applies the results of the copy shader during the draw. + * + * If you wish to copy the target without any effects see the `copyToGame` method instead. + * + * This method should be the final thing called in your pipeline. + * @param source The Render Target to draw to the game. + */ + drawToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; + + /** + * This method will copy the given Render Target to the game canvas using the `gameShader`. + * + * Unless you've changed it, the `gameShader` copies the target without modifying it, just + * ensuring it is placed in the correct location on the canvas. + * + * If you wish to draw the target with and apply the fragment shader at the same time, + * see the `drawToGame` method instead. + * + * This method should be the final thing called in your pipeline. + * @param source The Render Target to copy to the game. + */ + copyToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; + + /** + * This method is called by `drawToGame` and `copyToGame`. It takes the source Render Target + * and copies it back to the game canvas, or the next frame buffer in the stack, and should + * be considered the very last thing this pipeline does. + * + * You don't normally need to call this method, or override it, however it is left public + * should you wish to do so. + * + * Note that it does _not_ set a shader. You should do this yourself if invoking this. + * @param source The Render Target to draw to the game. + */ + bindAndDraw(source: Phaser.Renderer.WebGL.RenderTarget): void; + + /** + * This method is called every time the `batchSprite` method is called and is passed a + * reference to the current render target. + * + * If you override this method, then it should make sure it calls either the + * `drawToGame` or `copyToGame` methods as the final thing it does. However, you can do as + * much additional processing as you like prior to this. + * @param target The Render Target to draw to the game. + * @param swapTarget The Swap Render Target, useful for double-buffer effects. + * @param altSwapTarget The Swap Render Target, useful for double-buffer effects. + */ + onDraw(target: Phaser.Renderer.WebGL.RenderTarget, swapTarget?: Phaser.Renderer.WebGL.RenderTarget, altSwapTarget?: Phaser.Renderer.WebGL.RenderTarget): void; + + /** + * Set the UV values for the 6 vertices that make up the quad used by the copy shader. + * + * 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 copy shaders + * 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; + + /** + * Resets the quad vertice UV values to their default settings. + * + * The quad is used by the copy shader in this pipeline. + */ + resetUVs(): void; + + /** + * Destroys all shader instances, removes all object references and nulls all external references. + */ + destroy(): this; + + } + + /** + * 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. + * @param flipY Flip the UV on the Y axis before drawing? Default false. + */ + blitFrame(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean, flipY?: 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: string; - - /** - * The Scale Manager tried to enter fullscreen mode but failed. - */ - const FULLSCREEN_FAILED: string; - - /** - * The Scale Manager tried to enter fullscreen mode, but it is unsupported by the browser. - */ - const FULLSCREEN_UNSUPPORTED: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - } - /** * The Scale Manager handles the scaling, resizing and alignment of the game canvas. * @@ -88624,11 +87185,10 @@ declare namespace Phaser { onFullScreenError(): void; /** - * Get Rectange of visible area. - * @param camera The camera this viewport is respond upon. + * Get Rectange of visible area, this Rectange does NOT factor in camera scroll. * @param out The Rectangle of visible area. */ - getViewPort(camera?: Phaser.Cameras.Scene2D.Camera, out?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle; + getViewPort(out?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle; /** * Internal method, called automatically by the game step. @@ -88696,6 +87256,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. @@ -88797,386 +87533,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 The scene key or 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.events.on('addedtoscene', listener)`. - */ - const ADDED_TO_SCENE: string; - - /** - * 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.events.on('boot', listener)`. - */ - const BOOT: string; - - /** - * 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.events.on('create', listener)`. - */ - const CREATE: string; - - /** - * 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.events.on('destroy', listener)`. - * - * You should destroy any resources that may be in use by your Scene in this event handler. - */ - const DESTROY: string; - - /** - * 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.events.on('pause', listener)`. - */ - const PAUSE: string; - - /** - * 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.events.on('postupdate', listener)`. - * - * A Scene will only run its step if it is active. - */ - const POST_UPDATE: string; - - /** - * 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.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: string; - - /** - * 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.events.on('preupdate', listener)`. - * - * A Scene will only run its step if it is active. - */ - const PRE_UPDATE: string; - - /** - * 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.events.on('ready', listener)`. - */ - const READY: string; - - /** - * 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.events.on('removedfromscene', listener)`. - */ - const REMOVED_FROM_SCENE: string; - - /** - * 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.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: string; - - /** - * 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.events.on('resume', listener)`. - */ - const RESUME: string; - - /** - * 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.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: string; - - /** - * 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.events.on('sleep', listener)`. - */ - const SLEEP: string; - - /** - * 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.events.on('start', listener)`. - */ - const START: string; - - /** - * 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.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: string; - - /** - * 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.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: string; - - /** - * 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.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: string; - - /** - * 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.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: string; - - /** - * 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.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: string; - - /** - * 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 and the Scene is in a Running state, otherwise this is skipped. - * 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.events.on('update', listener)`. - * - * A Scene will only run its step if it is active. - */ - const UPDATE: string; - - /** - * 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.events.on('wake', listener)`. - */ - const WAKE: string; - - } - /** * 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. @@ -89241,14 +87795,6 @@ declare namespace Phaser { */ customViewports: number; - /** - * This system Scene is created during `bootQueue` and is a default - * empty Scene that lives outside of the Scene list, but can be used - * by plugins and managers that need access to a live Scene, without - * being tied to one. - */ - systemScene: Phaser.Scenes.Scene; - /** * Process the Scene operations queue. */ @@ -89272,7 +87818,7 @@ declare namespace Phaser { * @param autoStart If `true` the Scene will be started immediately after being added. Default false. * @param data Optional data object. This will be set as `Scene.settings.data` and passed to `Scene.init`, and `Scene.create`. */ - add(key: string, sceneConfig: Phaser.Types.Scenes.SceneType, autoStart?: boolean, data?: object): Phaser.Scene | null; + add(key: string, sceneConfig: Phaser.Scene | Phaser.Types.Scenes.SettingsConfig | Phaser.Types.Scenes.CreateSceneFromObjectConfig | Function, autoStart?: boolean, data?: object): Phaser.Scene | null; /** * Removes a Scene from the SceneManager. @@ -89592,7 +88138,7 @@ declare namespace Phaser { * @param autoStart If `true` the Scene will be started immediately after being added. Default false. * @param data Optional data object. This will be set as `Scene.settings.data` and passed to `Scene.init`, and `Scene.create`. */ - add(key: string, sceneConfig: Phaser.Types.Scenes.SceneType, autoStart?: boolean, data?: object): Phaser.Scene | null; + add(key: string, sceneConfig: Phaser.Scene | Phaser.Types.Scenes.SettingsConfig | Phaser.Types.Scenes.CreateSceneFromObjectConfig | Function, autoStart?: boolean, data?: object): Phaser.Scene | null; /** * Launch the given Scene and run it in parallel with this one. @@ -90128,202 +88674,384 @@ 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 The scene key or 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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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 and the Scene is in a Running state, otherwise this is skipped. + * 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.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.events.on('wake', listener)`. + */ + const WAKE: any; + + } } @@ -90660,6 +89388,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. @@ -90674,7 +89410,7 @@ declare namespace Phaser { * music.play(); * ``` */ - const COMPLETE: string; + const COMPLETE: any; /** * The Audio Data Decoded All Event. @@ -90692,7 +89428,7 @@ declare namespace Phaser { * this.sound.decodeAudio([ audioFiles ]); * ``` */ - const DECODED_ALL: string; + const DECODED_ALL: any; /** * The Audio Data Decoded Event. @@ -90706,7 +89442,7 @@ declare namespace Phaser { * this.sound.decodeAudio(key, audioData); * ``` */ - const DECODED: string; + const DECODED: any; /** * The Sound Destroy Event. @@ -90722,7 +89458,7 @@ declare namespace Phaser { * music.destroy(); * ``` */ - const DESTROY: string; + const DESTROY: any; /** * The Sound Detune Event. @@ -90738,7 +89474,7 @@ declare namespace Phaser { * music.setDetune(200); * ``` */ - const DETUNE: string; + const DETUNE: any; /** * The Sound Manager Global Detune Event. @@ -90749,7 +89485,7 @@ declare namespace Phaser { * * Listen to it from a Scene using: `this.sound.on('rate', listener)`. */ - const GLOBAL_DETUNE: string; + const GLOBAL_DETUNE: any; /** * The Sound Manager Global Mute Event. @@ -90759,7 +89495,7 @@ declare namespace Phaser { * * Listen to it from a Scene using: `this.sound.on('mute', listener)`. */ - const GLOBAL_MUTE: string; + const GLOBAL_MUTE: any; /** * The Sound Manager Global Rate Event. @@ -90770,7 +89506,7 @@ declare namespace Phaser { * * Listen to it from a Scene using: `this.sound.on('rate', listener)`. */ - const GLOBAL_RATE: string; + const GLOBAL_RATE: any; /** * The Sound Manager Global Volume Event. @@ -90780,7 +89516,7 @@ declare namespace Phaser { * * Listen to it from a Scene using: `this.sound.on('volume', listener)`. */ - const GLOBAL_VOLUME: string; + const GLOBAL_VOLUME: any; /** * The Sound Looped Event. @@ -90798,7 +89534,7 @@ declare namespace Phaser { * * This is not to be confused with the [LOOP]{@linkcode Phaser.Sound.Events#event:LOOP} event, which only emits when the loop state of a Sound is changed. */ - const LOOPED: string; + const LOOPED: any; /** * The Sound Loop Event. @@ -90815,7 +89551,7 @@ declare namespace Phaser { * * This is not to be confused with the [LOOPED]{@linkcode Phaser.Sound.Events#event:LOOPED} event, which emits each time a Sound loops during playback. */ - const LOOP: string; + const LOOP: any; /** * The Sound Mute Event. @@ -90831,7 +89567,7 @@ declare namespace Phaser { * music.setMute(true); * ``` */ - const MUTE: string; + const MUTE: any; /** * The Sound Pan Event. @@ -90847,7 +89583,7 @@ declare namespace Phaser { * sound.setPan(0.5); * ``` */ - const PAN: string; + const PAN: any; /** * The Pause All Sounds Event. @@ -90858,7 +89594,7 @@ declare namespace Phaser { * * Listen to it from a Scene using: `this.sound.on('pauseall', listener)`. */ - const PAUSE_ALL: string; + const PAUSE_ALL: any; /** * The Sound Pause Event. @@ -90874,7 +89610,7 @@ declare namespace Phaser { * music.pause(); * ``` */ - const PAUSE: string; + const PAUSE: any; /** * The Sound Play Event. @@ -90889,7 +89625,7 @@ declare namespace Phaser { * music.play(); * ``` */ - const PLAY: string; + const PLAY: any; /** * The Sound Rate Change Event. @@ -90905,7 +89641,7 @@ declare namespace Phaser { * music.setRate(0.5); * ``` */ - const RATE: string; + const RATE: any; /** * The Resume All Sounds Event. @@ -90916,7 +89652,7 @@ declare namespace Phaser { * * Listen to it from a Scene using: `this.sound.on('resumeall', listener)`. */ - const RESUME_ALL: string; + const RESUME_ALL: any; /** * The Sound Resume Event. @@ -90933,7 +89669,7 @@ declare namespace Phaser { * music.resume(); * ``` */ - const RESUME: string; + const RESUME: any; /** * The Sound Seek Event. @@ -90949,7 +89685,7 @@ declare namespace Phaser { * music.setSeek(5000); * ``` */ - const SEEK: string; + const SEEK: any; /** * The Stop All Sounds Event. @@ -90960,7 +89696,7 @@ declare namespace Phaser { * * Listen to it from a Scene using: `this.sound.on('stopall', listener)`. */ - const STOP_ALL: string; + const STOP_ALL: any; /** * The Sound Stop Event. @@ -90976,7 +89712,7 @@ declare namespace Phaser { * music.stop(); * ``` */ - const STOP: string; + const STOP: any; /** * The Sound Manager Unlocked Event. @@ -90987,7 +89723,7 @@ declare namespace Phaser { * * Listen to it from a Scene using: `this.sound.on('unlocked', listener)`. */ - const UNLOCKED: string; + const UNLOCKED: any; /** * The Sound Volume Event. @@ -91003,7 +89739,7 @@ declare namespace Phaser { * music.setVolume(0.5); * ``` */ - const VOLUME: string; + const VOLUME: any; } @@ -91721,14 +90457,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. */ @@ -92124,31 +90852,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: string; - - /** - * 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: string; - - } - /** * List is a generic implementation of an ordered list which contains utility methods for retrieving, manipulating, and iterating items. */ @@ -93078,6 +91781,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 { @@ -93297,707 +92025,6 @@ declare namespace Phaser { } - /** - * Filter Types. - */ - enum FilterMode { - /** - * Linear filter type. - */ - LINEAR, - /** - * Nearest neighbor filter type. - */ - NEAREST, - } - - /** - * A Dynamic Texture is a special texture that allows you to draw textures, frames and most kind of - * Game Objects directly to it. - * - * You can take many complex objects and draw them to this one texture, which can then be used as the - * base texture for other Game Objects, such as Sprites. Should you then update this texture, all - * Game Objects using it will instantly be updated as well, reflecting the changes immediately. - * - * It's a powerful way to generate dynamic textures at run-time that are WebGL friendly and don't invoke - * expensive GPU uploads on each change. - * - * ```js - * const t = this.textures.addDynamicTexture('player', 64, 128); - * // draw objects to t - * this.add.sprite(x, y, 'player'); - * ``` - * - * Because this is a standard Texture within Phaser, you can add frames to it, meaning you can use it - * to generate sprite sheets, texture atlases or tile sets. - * - * Under WebGL, a FrameBuffer, which is what this Dynamic Texture uses internally, cannot be anti-aliased. - * This means that when drawing objects such as Shapes or Graphics instances to this texture, they may appear - * to be drawn with no aliasing around the edges. This is a technical limitation of WebGL1. To get around it, - * create your shape as a texture in an art package, then draw that to this texture. - * - * Based on the assumption that you will be using this Dynamic Texture as a source for Sprites, it will - * automatically invert any drawing done to it on the y axis. If you do not require this, please call the - * `setIsSpriteTexture()` method and pass it `false` as its parameter. Do this before you start drawing - * to this texture, otherwise you will get vertically inverted frames under WebGL. This isn't required - * for Canvas. - */ - class DynamicTexture extends Phaser.Textures.Texture { - /** - * - * @param manager A reference to the Texture Manager this Texture belongs to. - * @param key The unique string-based key of this Texture. - * @param width The width of this Dymamic Texture in pixels. Defaults to 256 x 256. Default 256. - * @param height The height of this Dymamic Texture in pixels. Defaults to 256 x 256. Default 256. - */ - constructor(manager: Phaser.Textures.TextureManager, key: string, width?: number, height?: number); - - /** - * The internal data type of this object. - */ - readonly type: string; - - /** - * A reference to either the Canvas or WebGL Renderer that the Game instance is using. - */ - renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; - - /** - * This flag is set to 'true' during `beginDraw` and reset to 'false` in `endDraw`, - * allowing you to determine if this Dynamic Texture is batch drawing, or not. - */ - readonly isDrawing: boolean; - - /** - * A reference to the Rendering Context belonging to the Canvas Element this Dynamic Texture is drawing to. - */ - canvas: HTMLCanvasElement; - - /** - * Is this Dynamic Texture dirty or not? If not it won't spend time clearing or filling itself. - */ - dirty: boolean; - - /** - * Is this Dynamic Texture being used as the base texture for a Sprite Game Object? - * - * This is enabled by default, as we expect that will be the core use for Dymamic Textures. - * - * However, to disable it, call `RenderTexture.setIsSpriteTexture(false)`. - * - * You should do this _before_ drawing to this texture, so that it correctly - * inverses the frames for WebGL rendering. Not doing so will result in vertically flipped frames. - * - * This property is used in the `endDraw` method. - */ - isSpriteTexture: boolean; - - /** - * An internal Camera that can be used to move around this Dynamic Texture. - * - * Control it just like you would any Scene Camera. The difference is that it only impacts - * the placement of Game Objects that you then draw to this texture. - * - * You can scroll, zoom and rotate this Camera. - */ - camera: Phaser.Cameras.Scene2D.BaseCamera; - - /** - * The Render Target that belongs to this Dynamic Texture. - * - * A Render Target encapsulates a framebuffer and texture for the WebGL Renderer. - * - * This property remains `null` under Canvas. - */ - renderTarget: Phaser.Renderer.WebGL.RenderTarget; - - /** - * A reference to the WebGL Single Pipeline. - * - * This property remains `null` under Canvas. - */ - pipeline: Phaser.Renderer.WebGL.Pipelines.SinglePipeline; - - /** - * Resizes this Dynamic Texture to the new dimensions given. - * - * In WebGL it will destroy and then re-create the frame buffer being used by this Dynamic Texture. - * In Canvas it will resize the underlying canvas DOM element. - * - * Both approaches will erase everything currently drawn to this texture. - * - * If the dimensions given are the same as those already being used, calling this method will do nothing. - * @param width The new width of this Dynamic Texture. - * @param height The new height of this Dynamic Texture. If not specified, will be set the same as the `width`. Default width. - */ - setSize(width: number, height?: number): this; - - /** - * If you are planning on using this Render Texture as a base texture for Sprite - * Game Objects, then you should call this method with a value of `true` before - * drawing anything to it, otherwise you will get inverted frames in WebGL. - * @param value Is this Render Target being used as a Sprite Texture, or not? - */ - setIsSpriteTexture(value: boolean): this; - - /** - * Fills this Dynamic Texture with the given color. - * - * By default it will fill the entire texture, however you can set it to fill a specific - * rectangular area by using the x, y, width and height arguments. - * - * The color should be given in hex format, i.e. 0xff0000 for red, 0x00ff00 for green, etc. - * @param rgb The color to fill this Dynamic Texture with, such as 0xff0000 for red. - * @param alpha The alpha value used by the fill. Default 1. - * @param x The left coordinate of the fill rectangle. Default 0. - * @param y The top coordinate of the fill rectangle. Default 0. - * @param width The width of the fill rectangle. Default this.width. - * @param height The height of the fill rectangle. Default this.height. - */ - fill(rgb: number, alpha?: number, x?: number, y?: number, width?: number, height?: number): this; - - /** - * Fully clears this Dynamic Texture, erasing everything from it and resetting it back to - * a blank, transparent, texture. - */ - clear(): this; - - /** - * Takes the given texture key and frame and then stamps it at the given - * x and y coordinates. You can use the optional 'config' argument to provide - * lots more options about how the stamp is applied, including the alpha, - * tint, angle, scale and origin. - * - * By default, the frame will stamp on the x/y coordinates based on its center. - * - * If you wish to stamp from the top-left, set the config `originX` and - * `originY` properties both to zero. - * @param key The key of the texture to be used, as stored in the Texture Manager. - * @param frame The name or index of the frame within the Texture. Set to `null` to skip this argument if not required. - * @param x The x position to draw the frame at. Default 0. - * @param y The y position to draw the frame at. Default 0. - * @param config The stamp configuration object, allowing you to set the alpha, tint, angle, scale and origin of the stamp. - */ - stamp(key: string, frame?: string | number, x?: number, y?: number, config?: Phaser.Types.Textures.StampConfig): this; - - /** - * Draws the given object, or an array of objects, to this Dynamic Texture using a blend mode of ERASE. - * This has the effect of erasing any filled pixels present in the objects from this texture. - * - * It can accept any of the following: - * - * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. - * * Tilemap Layers. - * * A Group. The contents of which will be iterated and drawn in turn. - * * A Container. The contents of which will be iterated fully, and drawn in turn. - * * A Scene Display List. Pass in `Scene.children` to draw the whole list. - * * Another Dynamic Texture, or a Render Texture. - * * A Texture Frame instance. - * * A string. This is used to look-up the texture from the Texture Manager. - * - * Note: You cannot erase a Dynamic Texture from itself. - * - * If passing in a Group or Container it will only draw children that return `true` - * when their `willRender()` method is called. I.e. a Container with 10 children, - * 5 of which have `visible=false` will only draw the 5 visible ones. - * - * If passing in an array of Game Objects it will draw them all, regardless if - * they pass a `willRender` check or not. - * - * You can pass in a string in which case it will look for a texture in the Texture - * Manager matching that string, and draw the base frame. - * - * You can pass in the `x` and `y` coordinates to draw the objects at. The use of - * the coordinates differ based on what objects are being drawn. If the object is - * a Group, Container or Display List, the coordinates are _added_ to the positions - * of the children. For all other types of object, the coordinates are exact. - * - * Calling this method causes the WebGL batch to flush, so it can write the texture - * data to the framebuffer being used internally. The batch is flushed at the end, - * after the entries have been iterated. So if you've a bunch of objects to draw, - * try and pass them in an array in one single call, rather than making lots of - * separate calls. - * - * If you are not planning on using this Dynamic Texture as a base texture for Sprite - * Game Objects, then you should set `DynamicTexture.isSpriteTexture = false` before - * calling this method, otherwise you will get vertically inverted frames in WebGL. - * @param entries Any renderable Game Object, or Group, Container, Display List, Render Texture, Texture Frame, or an array of any of these. - * @param x The x position to draw the Frame at, or the offset applied to the object. Default 0. - * @param y The y position to draw the Frame at, or the offset applied to the object. Default 0. - */ - erase(entries: any, x?: number, y?: number): this; - - /** - * Draws the given object, or an array of objects, to this Dynamic Texture. - * - * It can accept any of the following: - * - * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. - * * Tilemap Layers. - * * A Group. The contents of which will be iterated and drawn in turn. - * * A Container. The contents of which will be iterated fully, and drawn in turn. - * * A Scene Display List. Pass in `Scene.children` to draw the whole list. - * * Another Dynamic Texture, or a Render Texture. - * * A Texture Frame instance. - * * A string. This is used to look-up the texture from the Texture Manager. - * - * Note 1: You cannot draw a Dynamic Texture to itself. - * - * Note 2: For Game Objects that have Post FX Pipelines, the pipeline _cannot_ be - * used when drawn to this texture. - * - * If passing in a Group or Container it will only draw children that return `true` - * when their `willRender()` method is called. I.e. a Container with 10 children, - * 5 of which have `visible=false` will only draw the 5 visible ones. - * - * If passing in an array of Game Objects it will draw them all, regardless if - * they pass a `willRender` check or not. - * - * You can pass in a string in which case it will look for a texture in the Texture - * Manager matching that string, and draw the base frame. If you need to specify - * exactly which frame to draw then use the method `drawFrame` instead. - * - * You can pass in the `x` and `y` coordinates to draw the objects at. The use of - * the coordinates differ based on what objects are being drawn. If the object is - * a Group, Container or Display List, the coordinates are _added_ to the positions - * of the children. For all other types of object, the coordinates are exact. - * - * The `alpha` and `tint` values are only used by Texture Frames. - * Game Objects use their own alpha and tint values when being drawn. - * - * Calling this method causes the WebGL batch to flush, so it can write the texture - * data to the framebuffer being used internally. The batch is flushed at the end, - * after the entries have been iterated. So if you've a bunch of objects to draw, - * try and pass them in an array in one single call, rather than making lots of - * separate calls. - * - * If you are not planning on using this Dynamic Texture as a base texture for Sprite - * Game Objects, then you should set `DynamicTexture.isSpriteTexture = false` before - * calling this method, otherwise you will get vertically inverted frames in WebGL. - * @param entries Any renderable Game Object, or Group, Container, Display List, other Render Texture, Texture Frame or an array of any of these. - * @param x The x position to draw the Frame at, or the offset applied to the object. Default 0. - * @param y The y position to draw the Frame at, or the offset applied to the object. Default 0. - * @param alpha The alpha value. Only used when drawing Texture Frames to this texture. Game Objects use their own alpha. Default 1. - * @param tint The tint color value. Only used when drawing Texture Frames to this texture. Game Objects use their own tint. WebGL only. Default 0xffffff. - */ - draw(entries: any, x?: number, y?: number, alpha?: number, tint?: number): this; - - /** - * Draws the Texture Frame to the Render Texture at the given position. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * - * ```javascript - * var rt = this.add.renderTexture(0, 0, 800, 600); - * rt.drawFrame(key, frame); - * ``` - * - * You can optionally provide a position, alpha and tint value to apply to the frame - * before it is drawn. - * - * Calling this method will cause a batch flush, so if you've got a stack of things to draw - * in a tight loop, try using the `draw` method instead. - * - * If you need to draw a Sprite to this Render Texture, use the `draw` method instead. - * - * If you are not planning on using this Dynamic Texture as a base texture for Sprite - * Game Objects, then you should set `DynamicTexture.isSpriteTexture = false` before - * calling this method, otherwise you will get vertically inverted frames in WebGL. - * @param key The key of the texture to be used, as stored in the Texture Manager. - * @param frame The name or index of the frame within the Texture. Set to `null` to skip this argument if not required. - * @param x The x position to draw the frame at. Default 0. - * @param y The y position to draw the frame at. Default 0. - * @param alpha The alpha value. Only used when drawing Texture Frames to this texture. Default 1. - * @param tint The tint color value. Only used when drawing Texture Frames to this texture. WebGL only. Default 0xffffff. - */ - drawFrame(key: string, frame?: string | number, x?: number, y?: number, alpha?: number, tint?: number): this; - - /** - * Takes the given Texture Frame and draws it to this Dynamic Texture as a fill pattern, - * i.e. in a grid-layout based on the frame dimensions. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * - * You can optionally provide a position, width, height, alpha and tint value to apply to - * the frames before they are drawn. The position controls the top-left where the repeating - * fill will start from. The width and height control the size of the filled area. - * - * The position can be negative if required, but the dimensions cannot. - * - * Calling this method will cause a batch flush by default. Use the `skipBatch` argument - * to disable this if this call is part of a larger batch draw. - * - * If you are not planning on using this Dynamic Texture as a base texture for Sprite - * Game Objects, then you should set `DynamicTexture.isSpriteTexture = false` before - * calling this method, otherwise you will get vertically inverted frames in WebGL. - * @param key The key of the texture to be used, as stored in the Texture Manager. - * @param frame The name or index of the frame within the Texture. Set to `null` to skip this argument if not required. - * @param x The x position to start drawing the frames from (can be negative to offset). Default 0. - * @param y The y position to start drawing the frames from (can be negative to offset). Default 0. - * @param width The width of the area to repeat the frame within. Defaults to the width of this Dynamic Texture. Default this.width. - * @param height The height of the area to repeat the frame within. Defaults to the height of this Dynamic Texture. Default this.height. - * @param alpha The alpha to use. Defaults to 1, no alpha. Default 1. - * @param tint WebGL only. The tint color to use. Leave as undefined, or 0xffffff to have no tint. Default 0xffffff. - * @param skipBatch Skip beginning and ending a batch with this call. Use if this is part of a bigger batched draw. Default false. - */ - repeat(key: string, frame?: string | number, x?: number, y?: number, width?: number, height?: number, alpha?: number, tint?: number, skipBatch?: boolean): this; - - /** - * Use this method if you need to batch draw a large number of Game Objects to - * this Dynamic Texture in a single pass, or on a frequent basis. This is especially - * useful under WebGL, however, if your game is using Canvas only, it will not make - * any speed difference in that situation. - * - * This method starts the beginning of a batched draw, unless one is already open. - * - * Batched drawing is faster than calling `draw` in loop, but you must be careful - * to manage the flow of code and remember to call `endDraw()` when you're finished. - * - * If you don't need to draw large numbers of objects it's much safer and easier - * to use the `draw` method instead. - * - * The flow should be: - * - * ```javascript - * // Call once: - * DynamicTexture.beginDraw(); - * - * // repeat n times: - * DynamicTexture.batchDraw(); - * // or - * DynamicTexture.batchDrawFrame(); - * - * // Call once: - * DynamicTexture.endDraw(); - * ``` - * - * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you - * have started a batch. Also, be very careful not to destroy this Dynamic Texture while the - * batch is still open. Doing so will cause a run-time error in the WebGL Renderer. - * - * You can use the `DynamicTexture.isDrawing` boolean property to tell if a batch is - * currently open, or not. - */ - beginDraw(): this; - - /** - * Use this method if you have already called `beginDraw` and need to batch - * draw a large number of objects to this Dynamic Texture. - * - * This method batches the drawing of the given objects to this texture, - * without causing a WebGL bind or batch flush for each one. - * - * It is faster than calling `draw`, but you must be careful to manage the - * flow of code and remember to call `endDraw()`. If you don't need to draw large - * numbers of objects it's much safer and easier to use the `draw` method instead. - * - * The flow should be: - * - * ```javascript - * // Call once: - * DynamicTexture.beginDraw(); - * - * // repeat n times: - * DynamicTexture.batchDraw(); - * // or - * DynamicTexture.batchDrawFrame(); - * - * // Call once: - * DynamicTexture.endDraw(); - * ``` - * - * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you - * have started a batch. Also, be very careful not to destroy this Dynamic Texture while the - * batch is still open. Doing so will cause a run-time error in the WebGL Renderer. - * - * You can use the `DynamicTexture.isDrawing` boolean property to tell if a batch is - * currently open, or not. - * - * This method can accept any of the following: - * - * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. - * * Tilemap Layers. - * * A Group. The contents of which will be iterated and drawn in turn. - * * A Container. The contents of which will be iterated fully, and drawn in turn. - * * A Scene's Display List. Pass in `Scene.children` to draw the whole list. - * * Another Dynamic Texture or Render Texture. - * * A Texture Frame instance. - * * A string. This is used to look-up a texture from the Texture Manager. - * - * Note: You cannot draw a Dynamic Texture to itself. - * - * If passing in a Group or Container it will only draw children that return `true` - * when their `willRender()` method is called. I.e. a Container with 10 children, - * 5 of which have `visible=false` will only draw the 5 visible ones. - * - * If passing in an array of Game Objects it will draw them all, regardless if - * they pass a `willRender` check or not. - * - * You can pass in a string in which case it will look for a texture in the Texture - * Manager matching that string, and draw the base frame. If you need to specify - * exactly which frame to draw then use the method `drawFrame` instead. - * - * You can pass in the `x` and `y` coordinates to draw the objects at. The use of - * the coordinates differ based on what objects are being drawn. If the object is - * a Group, Container or Display List, the coordinates are _added_ to the positions - * of the children. For all other types of object, the coordinates are exact. - * - * The `alpha` and `tint` values are only used by Texture Frames. - * Game Objects use their own alpha and tint values when being drawn. - * @param entries Any renderable Game Object, or Group, Container, Display List, other Dynamic or Texture, Texture Frame or an array of any of these. - * @param x The x position to draw the Frame at, or the offset applied to the object. Default 0. - * @param y The y position to draw the Frame at, or the offset applied to the object. Default 0. - * @param alpha The alpha value. Only used when drawing Texture Frames to this texture. Game Objects use their own alpha. Default 1. - * @param tint The tint color value. Only used when drawing Texture Frames to this texture. Game Objects use their own tint. WebGL only. Default 0xffffff. - */ - batchDraw(entries: any, x?: number, y?: number, alpha?: number, tint?: number): this; - - /** - * Use this method if you have already called `beginDraw` and need to batch - * draw a large number of texture frames to this Dynamic Texture. - * - * This method batches the drawing of the given frames to this Dynamic Texture, - * without causing a WebGL bind or batch flush for each one. - * - * It is faster than calling `drawFrame`, but you must be careful to manage the - * flow of code and remember to call `endDraw()`. If you don't need to draw large - * numbers of frames it's much safer and easier to use the `drawFrame` method instead. - * - * The flow should be: - * - * ```javascript - * // Call once: - * DynamicTexture.beginDraw(); - * - * // repeat n times: - * DynamicTexture.batchDraw(); - * // or - * DynamicTexture.batchDrawFrame(); - * - * // Call once: - * DynamicTexture.endDraw(); - * ``` - * - * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you - * have started a batch. Also, be very careful not to destroy this Dynamic Texture while the - * batch is still open. Doing so will cause a run-time error in the WebGL Renderer. - * - * You can use the `DynamicTexture.isDrawing` boolean property to tell if a batch is - * currently open, or not. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * - * You can optionally provide a position, alpha and tint value to apply to the frame - * before it is drawn. - * @param key The key of the texture to be used, as stored in the Texture Manager. - * @param frame The name or index of the frame within the Texture. - * @param x The x position to draw the frame at. Default 0. - * @param y The y position to draw the frame at. Default 0. - * @param alpha The alpha value. Only used when drawing Texture Frames to this texture. Game Objects use their own alpha. Default 1. - * @param tint The tint color value. Only used when drawing Texture Frames to this texture. Game Objects use their own tint. WebGL only. Default 0xffffff. - */ - batchDrawFrame(key: string, frame?: string | number, x?: number, y?: number, alpha?: number, tint?: number): this; - - /** - * Use this method to finish batch drawing to this Dynamic Texture. - * - * Doing so will stop the WebGL Renderer from capturing draws and then blit the - * framebuffer to the Render Target owned by this texture. - * - * Calling this method without first calling `beginDraw` will have no effect. - * - * Batch drawing is faster than calling `draw`, but you must be careful to manage the - * flow of code and remember to call `endDraw()` when you're finished. - * - * If you don't need to draw large numbers of objects it's much safer and easier - * to use the `draw` method instead. - * - * The flow should be: - * - * ```javascript - * // Call once: - * DynamicTexture.beginDraw(); - * - * // repeat n times: - * DynamicTexture.batchDraw(); - * // or - * DynamicTexture.batchDrawFrame(); - * - * // Call once: - * DynamicTexture.endDraw(); - * ``` - * - * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you - * have started a batch. Also, be very careful not to destroy this Dynamic Texture while the - * batch is still open. Doing so will cause a run-time error in the WebGL Renderer. - * - * You can use the `DynamicTexture.isDrawing` boolean property to tell if a batch is - * currently open, or not. - * @param erase Draws all objects in this batch using a blend mode of ERASE. This has the effect of erasing any filled pixels in the objects being drawn. Default false. - */ - endDraw(erase?: boolean): this; - - /** - * Takes a snapshot of the given area of this Dynamic Texture. - * - * The snapshot is taken immediately, but the results are returned via the given callback. - * - * To capture the whole Dynamic Texture see the `snapshot` method. - * To capture just a specific pixel, see the `snapshotPixel` method. - * - * Snapshots work by using the WebGL `readPixels` feature to grab every pixel from the frame buffer - * into an ArrayBufferView. It then parses this, copying the contents to a temporary Canvas and finally - * creating an Image object from it, which is the image returned to the callback provided. - * - * All in all, this is a computationally expensive and blocking process, which gets more expensive - * the larger the resolution this Dynamic Texture has, so please be careful how you employ this in your game. - * @param x The x coordinate to grab from. - * @param y The y coordinate to grab from. - * @param width The width of the area to grab. - * @param height The height of the area to grab. - * @param callback The Function to invoke after the snapshot image is created. - * @param type The format of the image to create, usually `image/png` or `image/jpeg`. Default 'image/png'. - * @param encoderOptions The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. Default 0.92. - */ - snapshotArea(x: number, y: number, width: number, height: number, callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback, type?: string, encoderOptions?: number): this; - - /** - * Takes a snapshot of the whole of this Dynamic Texture. - * - * The snapshot is taken immediately, but the results are returned via the given callback. - * - * To capture a portion of this Dynamic Texture see the `snapshotArea` method. - * To capture just a specific pixel, see the `snapshotPixel` method. - * - * Snapshots work by using the WebGL `readPixels` feature to grab every pixel from the frame buffer - * into an ArrayBufferView. It then parses this, copying the contents to a temporary Canvas and finally - * creating an Image object from it, which is the image returned to the callback provided. - * - * All in all, this is a computationally expensive and blocking process, which gets more expensive - * the larger the resolution this Dynamic Texture has, so please be careful how you employ this in your game. - * @param callback The Function to invoke after the snapshot image is created. - * @param type The format of the image to create, usually `image/png` or `image/jpeg`. Default 'image/png'. - * @param encoderOptions The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. Default 0.92. - */ - snapshot(callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback, type?: string, encoderOptions?: number): this; - - /** - * Takes a snapshot of the given pixel from this Dynamic Texture. - * - * The snapshot is taken immediately, but the results are returned via the given callback. - * - * To capture the whole Dynamic Texture see the `snapshot` method. - * To capture a portion of this Dynamic Texture see the `snapshotArea` method. - * - * Unlike the two other snapshot methods, this one will send your callback a `Color` object - * containing the color data for the requested pixel. It doesn't need to create an internal - * Canvas or Image object, so is a lot faster to execute, using less memory than the other snapshot methods. - * @param x The x coordinate of the pixel to get. - * @param y The y coordinate of the pixel to get. - * @param callback The Function to invoke after the snapshot pixel data is extracted. - */ - snapshotPixel(x: number, y: number, callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback): this; - - /** - * Renders this Dynamic Texture onto the Stamp Game Object as a BitmapMask. - * @param renderer A reference to the current active WebGL renderer. - * @param src The Game Object being rendered in this call. - * @param camera The Camera that is rendering the Game Object. - * @param parentMatrix This transform matrix is defined if the game object is nested - */ - renderWebGL(renderer: Phaser.Renderer.WebGL.WebGLRenderer, src: Phaser.GameObjects.Image, camera: Phaser.Cameras.Scene2D.Camera, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * This is a NOOP method. Bitmap Masks are not supported by the Canvas Renderer. - * @param renderer The Canvas Renderer which would be rendered to. - * @param mask The masked Game Object which would be rendered. - * @param camera The Camera to render to. - */ - renderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer, mask: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * Internal destroy handler, called as part of the destroy process. - */ - protected preDestroy(): void; - - } - - 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: string; - - /** - * The Texture Add Key Event. - * - * This event is dispatched by the Texture Manager when a texture with the given key is added to it. - * - * Listen to this event from within a Scene using: `this.textures.on('addtexture-key', listener)`. - */ - const ADD_KEY: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * 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: string; - - /** - * The Texture Remove Key Event. - * - * This event is dispatched by the Texture Manager when a texture with the given key is removed from it. - * - * Listen to this event from within a Scene using: `this.textures.on('removetexture-key', 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_KEY: string; - - } - /** * A Frame is a section of a Texture. */ @@ -94270,31 +92297,6 @@ declare namespace Phaser { } - /** - * Linear filter type. - */ - const LINEAR: number; - - /** - * Nearest Neighbor filter type. - */ - const NEAREST: number; - - namespace Parsers { - /** - * Parses a KTX format Compressed Texture file and generates texture data suitable for WebGL from it. - * @param data The data object created by the Compressed Texture File Loader. - */ - function KTXParser(data: ArrayBuffer): Phaser.Types.Textures.CompressedTextureData; - - /** - * Parses a PVR format Compressed Texture file and generates texture data suitable for WebGL from it. - * @param data The data object created by the Compressed Texture File Loader. - */ - function PVRParser(data: ArrayBuffer): Phaser.Types.Textures.CompressedTextureData; - - } - /** * 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 @@ -94477,16 +92479,12 @@ declare namespace Phaser { } /** - * When Phaser boots it will create an instance of this Texture Manager class. + * Textures are managed by the global TextureManager. This is a singleton class that is + * responsible for creating and delivering Textures and their corresponding Frames to Game Objects. * - * It is a global manager that handles all textures in your game. You can access it from within - * a Scene via the `this.textures` property. + * Sprites and other Game Objects get the texture data they need from the TextureManager. * - * Its role is as a manager for all textures that your game uses. It can create, update and remove - * textures globally, as well as parse texture data from external files, such as sprite sheets - * and texture atlases. - * - * Sprites and other texture-based Game Objects get their texture data directly from this class. + * Access it via `scene.textures`. */ class TextureManager extends Phaser.Events.EventEmitter { /** @@ -94496,43 +92494,21 @@ declare namespace Phaser { constructor(game: Phaser.Game); /** - * The Game that the Texture Manager belongs to. - * - * A game will only ever have one instance of a Texture Manager. + * The Game that this TextureManager belongs to. */ game: Phaser.Game; /** - * The internal name of this manager. + * The name of this manager. */ - readonly name: string; + name: string; /** - * This object contains all Textures that belong to this Texture Manager. - * - * Textures are identified by string-based keys, which are used as the property - * within this object. Therefore, you can access any texture directly from this - * object without any iteration. - * - * You should not typically modify this object directly, but instead use the - * methods provided by the Texture Manager to add and remove entries from it. + * An object that has all of textures that Texture Manager creates. + * Textures are assigned to keys so we can access to any texture that this object has directly by key value without iteration. */ list: object; - /** - * An Image Game Object that belongs to this Texture Manager. - * - * Used as a drawing stamp within Dynamic Textures. - * - * This is not part of the display list and doesn't render. - */ - readonly stamp: Phaser.GameObjects.Image; - - /** - * The crop Rectangle as used by the Stamp when it needs to crop itself. - */ - stampCrop: Phaser.Geom.Rectangle; - /** * Checks the given texture key and throws a console.warn if the key is already in use, then returns false. * @@ -94691,102 +92667,50 @@ declare namespace Phaser { addCanvas(key: string, source: HTMLCanvasElement, skipCache?: boolean): Phaser.Textures.CanvasTexture | null; /** - * Creates a Dynamic Texture instance and adds itself to this Texture Manager. - * - * A Dynamic Texture is a special texture that allows you to draw textures, frames and most kind of - * Game Objects directly to it. - * - * You can take many complex objects and draw them to this one texture, which can then be used as the - * base texture for other Game Objects, such as Sprites. Should you then update this texture, all - * Game Objects using it will instantly be updated as well, reflecting the changes immediately. - * - * It's a powerful way to generate dynamic textures at run-time that are WebGL friendly and don't invoke - * expensive GPU uploads on each change. - * - * See the methods available on the `DynamicTexture` class for more details. - * @param key The string-based key of this Texture. Must be unique within the Texture Manager. - * @param width The width of this Dymamic Texture in pixels. Defaults to 256 x 256. Default 256. - * @param height The height of this Dymamic Texture in pixels. Defaults to 256 x 256. Default 256. - */ - addDynamicTexture(key: string, width?: number, height?: number): Phaser.Textures.DynamicTexture | null; - - /** - * Adds a Texture Atlas to this Texture Manager. - * - * In Phaser terminology, a Texture Atlas is a combination of an atlas image and a JSON data file, - * such as those exported by applications like Texture Packer. - * + * Adds a new Texture Atlas to this Texture Manager. * It can accept either JSON Array or JSON Hash formats, as exported by Texture Packer and similar software. - * - * As of Phaser 3.60 you can use this method to add a atlas data to an existing Phaser Texture. * @param key The unique string-based key of the Texture. - * @param source The source Image element/s, or a Phaser Texture. - * @param data The Texture Atlas data/s. + * @param source The source Image element. + * @param data The Texture Atlas data. * @param dataSource An optional data Image element. */ - addAtlas(key: string, source: HTMLImageElement | HTMLImageElement[] | Phaser.Textures.Texture, data: object | object[], dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture | null; + addAtlas(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture | null; /** * Adds a Texture Atlas to this Texture Manager. - * - * In Phaser terminology, a Texture Atlas is a combination of an atlas image and a JSON data file, - * such as those exported by applications like Texture Packer. - * * The frame data of the atlas must be stored in an Array within the JSON. - * * This is known as a JSON Array in software such as Texture Packer. - * - * As of Phaser 3.60 you can use this method to add a atlas data to an existing Phaser Texture. * @param key The unique string-based key of the Texture. - * @param source The source Image element/s, or a Phaser Texture. + * @param source The source Image element/s. * @param data The Texture Atlas data/s. * @param dataSource An optional data Image element. */ - addAtlasJSONArray(key: string, source: HTMLImageElement | HTMLImageElement[] | Phaser.Textures.Texture, data: object | object[], dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture | null; + addAtlasJSONArray(key: string, source: HTMLImageElement | HTMLImageElement[], data: object | object[], dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture | null; /** * Adds a Texture Atlas to this Texture Manager. - * - * In Phaser terminology, a Texture Atlas is a combination of an atlas image and a JSON data file, - * such as those exported by applications like Texture Packer. - * * The frame data of the atlas must be stored in an Object within the JSON. - * * This is known as a JSON Hash in software such as Texture Packer. - * - * As of Phaser 3.60 you can use this method to add a atlas data to an existing Phaser Texture. * @param key The unique string-based key of the Texture. - * @param source The source Image element/s, or a Phaser Texture. - * @param data The Texture Atlas data/s. + * @param source The source Image element. + * @param data The Texture Atlas data. * @param dataSource An optional data Image element. */ - addAtlasJSONHash(key: string, source: HTMLImageElement | HTMLImageElement[] | Phaser.Textures.Texture, data: object | object[], dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture | null; + addAtlasJSONHash(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture | null; /** - * Adds a Texture Atlas to this Texture Manager. - * - * In Phaser terminology, a Texture Atlas is a combination of an atlas image and a data file, - * such as those exported by applications like Texture Packer. - * - * The frame data of the atlas must be stored in an XML file. - * - * As of Phaser 3.60 you can use this method to add a atlas data to an existing Phaser Texture. + * Adds a Texture Atlas to this Texture Manager, where the atlas data is given + * in the XML format. * @param key The unique string-based key of the Texture. - * @param source The source Image element, or a Phaser Texture. + * @param source The source Image element. * @param data The Texture Atlas XML data. * @param dataSource An optional data Image element. */ - addAtlasXML(key: string, source: HTMLImageElement | Phaser.Textures.Texture, data: object, dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture | null; + addAtlasXML(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture | null; /** * Adds a Unity Texture Atlas to this Texture Manager. - * - * In Phaser terminology, a Texture Atlas is a combination of an atlas image and a data file, - * such as those exported by applications like Texture Packer or Unity. - * - * The frame data of the atlas must be stored in a Unity YAML file. - * - * As of Phaser 3.60 you can use this method to add a atlas data to an existing Phaser Texture. + * The data must be in the form of a Unity YAML file. * @param key The unique string-based key of the Texture. * @param source The source Image element. * @param data The Texture Atlas data. @@ -94839,14 +92763,12 @@ declare namespace Phaser { * * If the key is `undefined` it will return the `__DEFAULT` Texture. * - * If the key is an instance of a Texture, it will return the instance. + * If the key is an instance of a Texture, it will return the key directly. * - * If the key is an instance of a Frame, it will return the frames parent Texture instance. - * - * Finally, if the key is given, but not found, and not a Texture or Frame instance, it will return the `__MISSING` Texture. - * @param key The unique string-based key of the Texture, or a Texture, or Frame instance. + * Finally. if the key is given, but not found and not a Texture instance, it will return the `__MISSING` Texture. + * @param key The unique string-based key of the Texture, or a Texture instance. */ - get(key: string | Phaser.Textures.Texture | Phaser.Textures.Frame): Phaser.Textures.Texture; + get(key: string | Phaser.Textures.Texture): Phaser.Textures.Texture; /** * Takes a Texture key and Frame name and returns a clone of that Frame if found. @@ -94862,20 +92784,6 @@ declare namespace Phaser { */ getFrame(key: string, frame?: string | number): Phaser.Textures.Frame; - /** - * Parses the 'key' parameter and returns a Texture Frame instance. - * - * It can accept the following formats: - * - * 1) A string - * 2) An array where the elements are: [ key, [frame] ] - * 3) An object with the properties: { key, [frame] } - * 4) A Texture instance - which returns the default frame from the Texture - * 5) A Frame instance - returns itself - * @param key The key to be parsed. - */ - parseFrame(key: string | any[] | object | Phaser.Textures.Texture | Phaser.Textures.Frame): Phaser.Textures.Frame; - /** * Returns an array with all of the keys of all Textures in this Texture Manager. * The output array will exclude the `__DEFAULT`, `__MISSING`, and `__WHITE` keys. @@ -94933,13 +92841,6 @@ declare namespace Phaser { */ each(callback: EachTextureCallback, scope: object, ...args: any[]): void; - /** - * Resets the internal Stamp object, ready for drawing and returns it. - * @param alpha The alpha to use. Default 1. - * @param tint WebGL only. The tint color to use. Default 0xffffff. - */ - resetStamp(alpha?: number, tint?: number): Phaser.GameObjects.Image; - /** * Destroys the Texture Manager and all Textures stored within it. */ @@ -94963,7 +92864,7 @@ declare namespace Phaser { * @param height Optional height of the source image. If not given it's derived from the source itself. * @param flipY Sets the `UNPACK_FLIP_Y_WEBGL` flag the WebGL Texture uses during upload. Default false. */ - constructor(texture: Phaser.Textures.Texture, source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | Phaser.GameObjects.RenderTexture | WebGLTexture | Phaser.Types.Textures.CompressedTextureData | Phaser.Textures.DynamicTexture, width?: number, height?: number, flipY?: boolean); + constructor(texture: Phaser.Textures.Texture, source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | Phaser.GameObjects.RenderTexture | WebGLTexture, width?: number, height?: number, flipY?: boolean); /** * A reference to the Canvas or WebGL Renderer. @@ -94982,7 +92883,7 @@ declare namespace Phaser { * * In Phaser 3.60 and above it can also be a Compressed Texture data object. */ - source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | Phaser.GameObjects.RenderTexture | WebGLTexture | Phaser.Types.Textures.CompressedTextureData | Phaser.Textures.DynamicTexture; + source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | Phaser.GameObjects.RenderTexture | WebGLTexture | Phaser.Types.Textures.CompressedTextureData; /** * The image data. @@ -95104,802 +93005,124 @@ 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 Add Key Event. + * + * This event is dispatched by the Texture Manager when a texture with the given key is added to it. + * + * Listen to this event from within a Scene using: `this.textures.on('addtexture-key', listener)`. + */ + const ADD_KEY: 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; + + /** + * The Texture Remove Key Event. + * + * This event is dispatched by the Texture Manager when a texture with the given key is removed from it. + * + * Listen to this event from within a Scene using: `this.textures.on('removetexture-key', 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_KEY: any; + + } + + /** + * Linear filter type. + */ + const LINEAR: number; + + /** + * Nearest Neighbor filter type. + */ + const NEAREST: number; + + namespace Parsers { + /** + * Parses a KTX format Compressed Texture file and generates texture data suitable for WebGL from it. + * @param data The data object created by the Compressed Texture File Loader. + */ + function KTXParser(data: ArrayBuffer): Phaser.Types.Textures.CompressedTextureData; + + /** + * Parses a PVR format Compressed Texture file and generates texture data suitable for WebGL from it. + * @param data The data object created by the Compressed Texture File Loader. + */ + function PVRParser(data: ArrayBuffer): Phaser.Types.Textures.CompressedTextureData; + + } + } 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 | null; - - /** - * 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 | null; - - /** - * 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 | null; - - /** - * 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 | null; - - /** - * 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 | undefined, 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 | undefined, 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 @@ -96004,324 +93227,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: Phaser.Types.Tilemaps.ObjectLayerConfig[]; - - /** - * 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[]; - - } - /** * The ObjectHelper helps tie objects with `gids` into the tileset * that sits behind them. @@ -96371,195 +93276,6 @@ declare namespace Phaser { } - 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 | null; - - } - - /** - * 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 group The current group layer from the Tiled JSON file. - * @param parentState The state of the parent group (if any). - */ - function CreateGroupLayer(json: object, group?: 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 | null; - - /** - * 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 @@ -98885,7 +95601,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -98900,7 +95615,7 @@ declare namespace Phaser { * reasons try to be careful about the construction of your Scene and the frequency of which blend modes * are used. */ - blendMode: Phaser.BlendModes | string | number; + blendMode: Phaser.BlendModes | string; /** * Sets the Blend Mode being used by this Game Object. @@ -98909,7 +95624,6 @@ declare namespace Phaser { * * Under WebGL only the following Blend Modes are available: * - * * NORMAL * * ADD * * MULTIPLY * * SCREEN @@ -98923,9 +95637,9 @@ declare namespace Phaser { * 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, a CONST or a number. + * @param value The BlendMode value. Either a string or a CONST. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setBlendMode(value: string | Phaser.BlendModes): this; /** * The native (un-scaled) width of this Game Object. @@ -99196,7 +95910,7 @@ declare namespace Phaser { * * 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 texture-based Game Object. + * 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; @@ -99782,6 +96496,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 | null; + + /** + * 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 | null; + + /** + * 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 | null; + + /** + * 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 | null; + + /** + * 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 | undefined, 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 | undefined, 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: Phaser.Types.Tilemaps.ObjectLayerConfig[]; + + /** + * 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 | null; + + } + + 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 group The current group layer from the Tiled JSON file. + * @param parentState The state of the parent group (if any). + */ + function CreateGroupLayer(json: object, group?: 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 | null; + + /** + * 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. */ @@ -100055,6 +98069,435 @@ declare namespace Phaser { } namespace Tweens { + /** + * The Tween Manager is a default Scene Plugin which controls and updates Tweens. + */ + 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; + + /** + * This toggles the updating state of this Tween Manager. + * + * Setting `paused` to `true` (or calling the `pauseAll` method) will + * stop this Tween Manager from updating any of its tweens, including + * newly created ones. Set back to `false` to resume playback. + */ + paused: boolean; + + /** + * Is this Tween Manager currently processing the tweens as part of + * its 'update' loop? This is set to 'true' at the start of 'update' + * and reset to 'false' at the end of the function. Allows you to trap + * Tween Manager status during tween callbacks. + */ + processing: boolean; + + /** + * An array of Tweens which are actively being processed by the Tween Manager. + */ + tweens: Phaser.Tweens.Tween[]; + + /** + * The time the Tween Manager was updated. + */ + time: number; + + /** + * The time the Tween Manager was started. + */ + startTime: number; + + /** + * The time the Tween Manager should next update. + */ + nextTime: number; + + /** + * The time the Tween Manager previously updated. + */ + prevTime: number; + + /** + * The maximum amount of time, in milliseconds, the browser can + * lag for, before lag smoothing is applied. + * + * See the `TweenManager.setLagSmooth` method for further details. + */ + maxLag: number; + + /** + * The amount of time, in milliseconds, that is used to set the + * delta when lag smoothing is applied. + * + * See the `TweenManager.setLagSmooth` method for further details. + */ + lagSkip: number; + + /** + * An internal value that holds the fps rate. + */ + gap: number; + + /** + * Create a Tween and return it, but does not add it to this Tween Manager. + * + * Please note that a Tween will not manipulate any target property that begins with an underscore. + * + * In order to play this tween, you'll need to add it to a Tween Manager via + * the `TweenManager.existing` method. + * + * You can optionally pass an **array** of Tween Configuration objects to this method and it will create + * one Tween per entry in the array. If an array is given, an array of tweens is returned. + * @param config A Tween Configuration object. Or an array of Tween Configuration objects. + */ + create(config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenBuilderConfig[] | object | object[]): Phaser.Tweens.Tween | Phaser.Tweens.Tween[]; + + /** + * Create a Tween and add it to this Tween Manager by passing a Tween Configuration object. + * + * Example, run from within a Scene: + * + * ```js + * const logo = this.add.image(100, 100, 'logo'); + * + * this.tweens.add({ + * targets: logo, + * x: 600, + * ease: 'Power1', + * duration: 2000 + * }); + * ``` + * + * See the `TweenBuilderConfig` for all of the options you have available. + * + * Playback will start immediately unless the tween has been configured to be paused. + * + * Please note that a Tween will not manipulate any target property that begins with an underscore. + * + * Tweens are designed to be 'fire-and-forget'. They automatically destroy themselves once playback + * is complete, to free-up memory and resources. If you wish to keep a tween after playback, i.e. to + * play it again at a later time, then you should set the `persist` property to `true` in the config. + * However, doing so means it's entirely up to _you_ to destroy the tween when you're finished with it, + * otherwise it will linger in memory forever. + * + * You can optionally pass an **array** of Tween Configuration objects to this method and it will create + * one Tween per entry in the array. If an array is given, an array of tweens is returned. + * + * If you wish to chain Tweens together for sequential playback, see the `TweenManager.chain` method. + * @param config A Tween Configuration object. Or an array of Tween Configuration objects. + */ + add(config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenBuilderConfig[] | object | object[]): Phaser.Tweens.Tween | Phaser.Tweens.Tween[]; + + /** + * Create a sequence of Tweens, chained to one-another, and add them to this Tween Manager. + * + * The tweens are played in order, from start to finish. You can optionally set the chain + * to repeat as many times as you like. Once the chain has finished playing, or repeating if set, + * all tweens in the chain will be destroyed automatically. To override this, set the 'persists' + * argument to 'true'. + * + * Playback will start immediately unless the _first_ Tween has been configured to be paused. + * + * Please note that Tweens will not manipulate any target property that begins with an underscore. + * @param tweens A Tween Chain configuration object, or an array of them to create multiple chains at once. + */ + chain(tweens: Phaser.Types.Tweens.TweenBuilderConfig[] | object[]): Phaser.Tweens.TweenChain | Phaser.Tweens.TweenChain[]; + + /** + * Returns an array containing this Tween and all Tweens chained to it, + * in the order in which they will be played. + * + * If there are no chained Tweens an empty array is returned. + * @param tween The Tween to return the chain from. + */ + getChainedTweens(tween: Phaser.Tweens.Tween): Phaser.Tweens.Tween[]; + + /** + * Check to see if the given Tween instance exists within this Tween Manager. + * + * Will return `true` as long as the Tween is being processed by this Tween Manager. + * + * Will return `false` if not present, or has a state of `REMOVED` or `DESTROYED`. + * @param tween The Tween instance to check. + */ + has(tween: Phaser.Tweens.Tween): boolean; + + /** + * Add an existing Tween to this Tween Manager. + * + * Playback will start immediately unless the tween has been configured to be paused. + * @param tween The Tween to add. + */ + existing(tween: Phaser.Tweens.Tween): this; + + /** + * Create a Number Tween and add it to the active Tween list. + * + * Playback will start immediately unless the tween has been configured to be paused. + * + * Please note that a Tween will not manipulate any target property that begins with an underscore. + * @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; + + /** + * Set the limits that are used when a browser encounters lag, or delays that cause the elapsed + * time between two frames to exceed the expected amount. If this occurs, the Tween Manager will + * act as if the 'skip' amount of times has passed, in order to maintain strict tween sequencing. + * + * This is enabled by default with the values 500ms for the lag limit and 33ms for the skip. + * + * You should not set these to low values, as it won't give time for the browser to ever + * catch-up with itself and reclaim sync. + * + * Call this method with no arguments to disable smoothing. + * + * Call it with the arguments `500` and `33` to reset to the defaults. + * @param limit If the browser exceeds this amount, in milliseconds, it will act as if the 'skip' amount has elapsed instead. Default 0. + * @param skip The amount, in milliseconds, to use as the step delta should the browser lag beyond the 'limit'. Default 0. + */ + setLagSmooth(limit?: number, skip?: number): this; + + /** + * Limits the Tween system to run at a particular frame rate. + * + * You should not set this _above_ the frequency of the browser, + * but instead can use it to throttle the frame rate lower, should + * you need to in certain situations. + * @param fps The frame rate to tick at. Default 240. + */ + setFps(fps?: number): this; + + /** + * Internal method that calculates the delta value, along with the other timing values, + * and returns the new delta. + * + * You should not typically call this method directly. + * @param tick Is this a manual tick, or an automated tick? Default false. + */ + getDelta(tick?: boolean): number; + + /** + * Manually advance the Tween system by one step. + * + * This will update all Tweens even if the Tween Manager is currently + * paused. + */ + tick(): this; + + /** + * Internal update handler. + * + * Calls `TweenManager.step` as long as the Tween Manager has not + * been paused. + */ + update(): void; + + /** + * Updates all Tweens belonging to this Tween Manager. + * + * Called automatically by `update` and `tick`. + * @param tick Is this a manual tick, or an automated tick? Default false. + */ + step(tick?: boolean): void; + + /** + * Removes the given Tween from this Tween Manager, even if it hasn't started + * playback yet. If this method is called while the Tween Manager is processing + * an update loop, then the tween will be flagged for removal at the start of + * the next frame. Otherwise, it is removed immediately. + * + * The removed tween is _not_ destroyed. It is just removed from this Tween Manager. + * @param tween The Tween to be removed. + */ + remove(tween: Phaser.Tweens.Tween): this; + + /** + * Resets the given Tween. + * + * If the Tween does not belong to this Tween Manager, it will first be added. + * + * Then it will seek to position 0 and playback will start on the next frame. + * @param tween The Tween to be reset. + */ + reset(tween: Phaser.Tweens.Tween): this; + + /** + * Checks if a Tween 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): this; + + /** + * 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[]): this; + + /** + * Returns an array containing references to all Tweens in this Tween Manager. + * + * It is safe to mutate the returned array. However, acting upon any of the Tweens + * within it, will adjust those stored in this Tween Manager, as they are passed + * by reference and not cloned. + * + * If you wish to get tweens for a specific target, see `getTweensOf`. + */ + getTweens(): Phaser.Tweens.Tween[]; + + /** + * Returns an array of all Tweens in the Tween Manager which affect the given target, or array of targets. + * + * It's possible for this method to return tweens that are about to be removed from + * the Tween Manager. You should check the state of the returned tween before acting + * upon it. + * @param target The target to look for. Provide an array to look for multiple targets. + */ + getTweensOf(target: object | any[]): Phaser.Tweens.Tween[]; + + /** + * Returns the scale of the time delta for all Tweens owned by this Tween Manager. + */ + getGlobalTimeScale(): number; + + /** + * 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): this; + + /** + * Checks if the given object is being affected by a _playing_ Tween. + * + * If the Tween is paused, this method will return false. + * @param target The object to check if a tween is active for it, or not. + */ + isTweening(target: object): boolean; + + /** + * Destroys all Tweens in this Tween Manager. + * + * The tweens will erase all references to any targets they hold + * and be stopped immediately. + * + * If this method is called while the Tween Manager is running its + * update process, then the tweens will be removed at the start of + * the next frame. Outside of this, they are removed immediately. + */ + killAll(): this; + + /** + * Stops all Tweens which affect the given target or array of targets. + * + * The tweens will erase all references to any targets they hold + * and be stopped immediately. + * + * If this method is called while the Tween Manager is running its + * update process, then the tweens will be removed at the start of + * the next frame. Outside of this, they are removed immediately. + * @param target The target to kill the tweens of. Provide an array to use multiple targets. + */ + killTweensOf(target: object | any[]): this; + + /** + * Pauses this Tween Manager. No Tweens will update while paused. + * + * This includes tweens created after this method was called. + * + * See `TweenManager#resumeAll` to resume the playback. + * + * As of Phaser 3.60 you can also toggle the boolean property `TweenManager.paused`. + */ + pauseAll(): this; + + /** + * Resumes playback of this Tween Manager. + * + * All active Tweens will continue updating. + * + * See `TweenManager#pauseAll` to pause the playback. + * + * As of Phaser 3.60 you can also toggle the boolean property `TweenManager.paused`. + */ + resumeAll(): this; + + /** + * 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. @@ -100219,7 +98662,7 @@ declare namespace Phaser { * Note that this event is usually dispatched already by the time you call `this.tweens.add()`, and is * meant for use with `tweens.create()` and/or `tweens.existing()`. */ - const TWEEN_ACTIVE: string; + const TWEEN_ACTIVE: any; /** * The Tween Complete Event. @@ -100243,7 +98686,7 @@ declare namespace Phaser { * tween.on('complete', listener); * ``` */ - const TWEEN_COMPLETE: string; + const TWEEN_COMPLETE: any; /** * The Tween Loop Event. @@ -100270,7 +98713,7 @@ declare namespace Phaser { * tween.on('loop', listener); * ``` */ - const TWEEN_LOOP: string; + const TWEEN_LOOP: any; /** * The Tween Pause Event. @@ -100291,7 +98734,7 @@ declare namespace Phaser { * tween.pause(); * ``` */ - const TWEEN_PAUSE: string; + const TWEEN_PAUSE: any; /** * The Tween Repeat Event. @@ -100318,7 +98761,7 @@ declare namespace Phaser { * tween.on('repeat', listener); * ``` */ - const TWEEN_REPEAT: string; + const TWEEN_REPEAT: any; /** * The Tween Resume Event. @@ -100339,7 +98782,7 @@ declare namespace Phaser { * tween.resume(); * ``` */ - const TWEEN_RESUME: string; + const TWEEN_RESUME: any; /** * The Tween Start Event. @@ -100362,7 +98805,7 @@ declare namespace Phaser { * tween.on('start', listener); * ``` */ - const TWEEN_START: string; + const TWEEN_START: any; /** * The Tween Stop Event. @@ -100381,7 +98824,7 @@ declare namespace Phaser { * tween.on('stop', listener); * ``` */ - const TWEEN_STOP: string; + const TWEEN_STOP: any; /** * The Tween Update Event. @@ -100404,7 +98847,7 @@ declare namespace Phaser { * tween.on('update', listener); * ``` */ - const TWEEN_UPDATE: string; + const TWEEN_UPDATE: any; /** * The Tween Yoyo Event. @@ -100432,7 +98875,7 @@ declare namespace Phaser { * tween.on('yoyo', listener); * ``` */ - const TWEEN_YOYO: string; + const TWEEN_YOYO: any; } @@ -101067,88 +99510,6 @@ declare namespace Phaser { } - /** - * Phaser Tween States. - */ - enum States { - /** - * TweenData state. - */ - CREATED, - /** - * TweenData state. - */ - DELAY, - /** - * TweenData state. - */ - PENDING_RENDER, - /** - * TweenData state. - */ - PLAYING_FORWARD, - /** - * TweenData state. - */ - PLAYING_BACKWARD, - /** - * TweenData state. - */ - HOLD_DELAY, - /** - * TweenData state. - */ - REPEAT_DELAY, - /** - * TweenData state. - */ - COMPLETE, - /** - * Tween state. The Tween has been created but has not yet been added to the Tween Manager. - */ - PENDING, - /** - * Tween state. The Tween is active within the Tween Manager. This means it is either playing, - * or was playing and is currently paused, but in both cases it's still being processed by - * the Tween Manager, so is considered 'active'. - */ - ACTIVE, - /** - * Tween state. The Tween is waiting for a loop countdown to elapse. - */ - LOOP_DELAY, - /** - * Tween state. The Tween is waiting for a complete delay to elapse. - */ - COMPLETE_DELAY, - /** - * Tween state. The Tween is waiting for a starting delay to elapse. - */ - START_DELAY, - /** - * Tween state. The Tween has finished playback and is waiting to be removed from the Tween Manager. - */ - PENDING_REMOVE, - /** - * Tween state. The Tween has been removed from the Tween Manager. - */ - REMOVED, - /** - * Tween state. The Tween has finished playback but was flagged as 'persistent' during creation, - * so will not be automatically removed by the Tween Manager. - */ - FINISHED, - /** - * Tween state. The Tween has been destroyed and can no longer be played by a Tween Manager. - */ - DESTROYED, - } - - /** - * Phaser Tween state constants. - */ - type StateType = Phaser.Tweens.States; - /** * 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 @@ -101773,437 +100134,98 @@ declare namespace Phaser { } /** - * The Tween Manager is a default Scene Plugin which controls and updates Tweens. + * Phaser Tween States. */ - class TweenManager { + enum States { /** - * - * @param scene The Scene which owns this Tween Manager. + * TweenData state. */ - constructor(scene: Phaser.Scene); - + CREATED, /** - * The Scene which owns this Tween Manager. + * TweenData state. */ - scene: Phaser.Scene; - + DELAY, /** - * The Systems object of the Scene which owns this Tween Manager. + * TweenData state. */ - systems: Phaser.Scenes.Systems; - + PENDING_RENDER, /** - * 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. + * TweenData state. */ - timeScale: number; - + PLAYING_FORWARD, /** - * This toggles the updating state of this Tween Manager. - * - * Setting `paused` to `true` (or calling the `pauseAll` method) will - * stop this Tween Manager from updating any of its tweens, including - * newly created ones. Set back to `false` to resume playback. + * TweenData state. */ - paused: boolean; - + PLAYING_BACKWARD, /** - * Is this Tween Manager currently processing the tweens as part of - * its 'update' loop? This is set to 'true' at the start of 'update' - * and reset to 'false' at the end of the function. Allows you to trap - * Tween Manager status during tween callbacks. + * TweenData state. */ - processing: boolean; - + HOLD_DELAY, /** - * An array of Tweens which are actively being processed by the Tween Manager. + * TweenData state. */ - tweens: Phaser.Tweens.Tween[]; - + REPEAT_DELAY, /** - * The time the Tween Manager was updated. + * TweenData state. */ - time: number; - + COMPLETE, /** - * The time the Tween Manager was started. + * Tween state. The Tween has been created but has not yet been added to the Tween Manager. */ - startTime: number; - + PENDING, /** - * The time the Tween Manager should next update. + * Tween state. The Tween is active within the Tween Manager. This means it is either playing, + * or was playing and is currently paused, but in both cases it's still being processed by + * the Tween Manager, so is considered 'active'. */ - nextTime: number; - + ACTIVE, /** - * The time the Tween Manager previously updated. + * Tween state. The Tween is waiting for a loop countdown to elapse. */ - prevTime: number; - + LOOP_DELAY, /** - * The maximum amount of time, in milliseconds, the browser can - * lag for, before lag smoothing is applied. - * - * See the `TweenManager.setLagSmooth` method for further details. + * Tween state. The Tween is waiting for a complete delay to elapse. */ - maxLag: number; - + COMPLETE_DELAY, /** - * The amount of time, in milliseconds, that is used to set the - * delta when lag smoothing is applied. - * - * See the `TweenManager.setLagSmooth` method for further details. + * Tween state. The Tween is waiting for a starting delay to elapse. */ - lagSkip: number; - + START_DELAY, /** - * An internal value that holds the fps rate. + * Tween state. The Tween has finished playback and is waiting to be removed from the Tween Manager. */ - gap: number; - + PENDING_REMOVE, /** - * Create a Tween and return it, but does not add it to this Tween Manager. - * - * Please note that a Tween will not manipulate any target property that begins with an underscore. - * - * In order to play this tween, you'll need to add it to a Tween Manager via - * the `TweenManager.existing` method. - * - * You can optionally pass an **array** of Tween Configuration objects to this method and it will create - * one Tween per entry in the array. If an array is given, an array of tweens is returned. - * @param config A Tween Configuration object. Or an array of Tween Configuration objects. + * Tween state. The Tween has been removed from the Tween Manager. */ - create(config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenBuilderConfig[] | object | object[]): Phaser.Tweens.Tween | Phaser.Tweens.Tween[]; - + REMOVED, /** - * Create a Tween and add it to this Tween Manager by passing a Tween Configuration object. - * - * Example, run from within a Scene: - * - * ```js - * const logo = this.add.image(100, 100, 'logo'); - * - * this.tweens.add({ - * targets: logo, - * x: 600, - * ease: 'Power1', - * duration: 2000 - * }); - * ``` - * - * See the `TweenBuilderConfig` for all of the options you have available. - * - * Playback will start immediately unless the tween has been configured to be paused. - * - * Please note that a Tween will not manipulate any target property that begins with an underscore. - * - * Tweens are designed to be 'fire-and-forget'. They automatically destroy themselves once playback - * is complete, to free-up memory and resources. If you wish to keep a tween after playback, i.e. to - * play it again at a later time, then you should set the `persist` property to `true` in the config. - * However, doing so means it's entirely up to _you_ to destroy the tween when you're finished with it, - * otherwise it will linger in memory forever. - * - * You can optionally pass an **array** of Tween Configuration objects to this method and it will create - * one Tween per entry in the array. If an array is given, an array of tweens is returned. - * - * If you wish to chain Tweens together for sequential playback, see the `TweenManager.chain` method. - * @param config A Tween Configuration object. Or an array of Tween Configuration objects. + * Tween state. The Tween has finished playback but was flagged as 'persistent' during creation, + * so will not be automatically removed by the Tween Manager. */ - add(config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenBuilderConfig[] | object | object[]): Phaser.Tweens.Tween | Phaser.Tweens.Tween[]; - + FINISHED, /** - * Create a sequence of Tweens, chained to one-another, and add them to this Tween Manager. - * - * The tweens are played in order, from start to finish. You can optionally set the chain - * to repeat as many times as you like. Once the chain has finished playing, or repeating if set, - * all tweens in the chain will be destroyed automatically. To override this, set the 'persists' - * argument to 'true'. - * - * Playback will start immediately unless the _first_ Tween has been configured to be paused. - * - * Please note that Tweens will not manipulate any target property that begins with an underscore. - * @param tweens A Tween Chain configuration object, or an array of them to create multiple chains at once. + * Tween state. The Tween has been destroyed and can no longer be played by a Tween Manager. */ - chain(tweens: Phaser.Types.Tweens.TweenChainBuilderConfig | Phaser.Types.Tweens.TweenChainBuilderConfig[] | object | object[]): Phaser.Tweens.TweenChain | Phaser.Tweens.TweenChain[]; - - /** - * Returns an array containing this Tween and all Tweens chained to it, - * in the order in which they will be played. - * - * If there are no chained Tweens an empty array is returned. - * @param tween The Tween to return the chain from. - */ - getChainedTweens(tween: Phaser.Tweens.Tween): Phaser.Tweens.Tween[]; - - /** - * Check to see if the given Tween instance exists within this Tween Manager. - * - * Will return `true` as long as the Tween is being processed by this Tween Manager. - * - * Will return `false` if not present, or has a state of `REMOVED` or `DESTROYED`. - * @param tween The Tween instance to check. - */ - has(tween: Phaser.Tweens.Tween): boolean; - - /** - * Add an existing Tween to this Tween Manager. - * - * Playback will start immediately unless the tween has been configured to be paused. - * @param tween The Tween to add. - */ - existing(tween: Phaser.Tweens.Tween): this; - - /** - * Create a Number Tween and add it to the active Tween list. - * - * Playback will start immediately unless the tween has been configured to be paused. - * - * Please note that a Tween will not manipulate any target property that begins with an underscore. - * @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; - - /** - * Set the limits that are used when a browser encounters lag, or delays that cause the elapsed - * time between two frames to exceed the expected amount. If this occurs, the Tween Manager will - * act as if the 'skip' amount of times has passed, in order to maintain strict tween sequencing. - * - * This is enabled by default with the values 500ms for the lag limit and 33ms for the skip. - * - * You should not set these to low values, as it won't give time for the browser to ever - * catch-up with itself and reclaim sync. - * - * Call this method with no arguments to disable smoothing. - * - * Call it with the arguments `500` and `33` to reset to the defaults. - * @param limit If the browser exceeds this amount, in milliseconds, it will act as if the 'skip' amount has elapsed instead. Default 0. - * @param skip The amount, in milliseconds, to use as the step delta should the browser lag beyond the 'limit'. Default 0. - */ - setLagSmooth(limit?: number, skip?: number): this; - - /** - * Limits the Tween system to run at a particular frame rate. - * - * You should not set this _above_ the frequency of the browser, - * but instead can use it to throttle the frame rate lower, should - * you need to in certain situations. - * @param fps The frame rate to tick at. Default 240. - */ - setFps(fps?: number): this; - - /** - * Internal method that calculates the delta value, along with the other timing values, - * and returns the new delta. - * - * You should not typically call this method directly. - * @param tick Is this a manual tick, or an automated tick? Default false. - */ - getDelta(tick?: boolean): number; - - /** - * Manually advance the Tween system by one step. - * - * This will update all Tweens even if the Tween Manager is currently - * paused. - */ - tick(): this; - - /** - * Internal update handler. - * - * Calls `TweenManager.step` as long as the Tween Manager has not - * been paused. - */ - update(): void; - - /** - * Updates all Tweens belonging to this Tween Manager. - * - * Called automatically by `update` and `tick`. - * @param tick Is this a manual tick, or an automated tick? Default false. - */ - step(tick?: boolean): void; - - /** - * Removes the given Tween from this Tween Manager, even if it hasn't started - * playback yet. If this method is called while the Tween Manager is processing - * an update loop, then the tween will be flagged for removal at the start of - * the next frame. Otherwise, it is removed immediately. - * - * The removed tween is _not_ destroyed. It is just removed from this Tween Manager. - * @param tween The Tween to be removed. - */ - remove(tween: Phaser.Tweens.Tween): this; - - /** - * Resets the given Tween. - * - * If the Tween does not belong to this Tween Manager, it will first be added. - * - * Then it will seek to position 0 and playback will start on the next frame. - * @param tween The Tween to be reset. - */ - reset(tween: Phaser.Tweens.Tween): this; - - /** - * Checks if a Tween 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): this; - - /** - * 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[]): this; - - /** - * Returns an array containing references to all Tweens in this Tween Manager. - * - * It is safe to mutate the returned array. However, acting upon any of the Tweens - * within it, will adjust those stored in this Tween Manager, as they are passed - * by reference and not cloned. - * - * If you wish to get tweens for a specific target, see `getTweensOf`. - */ - getTweens(): Phaser.Tweens.Tween[]; - - /** - * Returns an array of all Tweens in the Tween Manager which affect the given target, or array of targets. - * - * It's possible for this method to return tweens that are about to be removed from - * the Tween Manager. You should check the state of the returned tween before acting - * upon it. - * @param target The target to look for. Provide an array to look for multiple targets. - */ - getTweensOf(target: object | any[]): Phaser.Tweens.Tween[]; - - /** - * Returns the scale of the time delta for all Tweens owned by this Tween Manager. - */ - getGlobalTimeScale(): number; - - /** - * 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): this; - - /** - * Checks if the given object is being affected by a _playing_ Tween. - * - * If the Tween is paused, this method will return false. - * @param target The object to check if a tween is active for it, or not. - */ - isTweening(target: object): boolean; - - /** - * Destroys all Tweens in this Tween Manager. - * - * The tweens will erase all references to any targets they hold - * and be stopped immediately. - * - * If this method is called while the Tween Manager is running its - * update process, then the tweens will be removed at the start of - * the next frame. Outside of this, they are removed immediately. - */ - killAll(): this; - - /** - * Stops all Tweens which affect the given target or array of targets. - * - * The tweens will erase all references to any targets they hold - * and be stopped immediately. - * - * If this method is called while the Tween Manager is running its - * update process, then the tweens will be removed at the start of - * the next frame. Outside of this, they are removed immediately. - * @param target The target to kill the tweens of. Provide an array to use multiple targets. - */ - killTweensOf(target: object | any[]): this; - - /** - * Pauses this Tween Manager. No Tweens will update while paused. - * - * This includes tweens created after this method was called. - * - * See `TweenManager#resumeAll` to resume the playback. - * - * As of Phaser 3.60 you can also toggle the boolean property `TweenManager.paused`. - */ - pauseAll(): this; - - /** - * Resumes playback of this Tween Manager. - * - * All active Tweens will continue updating. - * - * See `TweenManager#pauseAll` to pause the playback. - * - * As of Phaser 3.60 you can also toggle the boolean property `TweenManager.paused`. - */ - resumeAll(): this; - - /** - * 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; - + DESTROYED, } + /** + * Phaser Tween state constants. + */ + type StateType = Phaser.Tweens.States; + } 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. @@ -102345,220 +100367,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. 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 above another one in the array. * The array is modified in-place. @@ -102844,6 +100652,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. 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 { @@ -102866,14 +100888,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. @@ -103112,12 +101126,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. * @@ -103126,6 +101134,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; + } } @@ -104033,14 +102047,14 @@ declare type EachSetCallback = (entry: E, index: number)=>boolean | null; declare type EachTextureCallback = (texture: Phaser.Textures.Texture, ...args: any[])=>void; -declare type FindTileCallback = (value: Phaser.Tilemaps.Tile, index: number, array: Phaser.Tilemaps.Tile[])=>boolean; - -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[])=>Phaser.GameObjects.GameObject; declare type TilemapFindCallback = (value: Phaser.GameObjects.GameObject, index: number, array: Phaser.GameObjects.GameObject[])=>boolean; +declare type FindTileCallback = (value: Phaser.Tilemaps.Tile, index: number, array: Phaser.Tilemaps.Tile[])=>boolean; + +declare type EachTileCallback = (value: Phaser.Tilemaps.Tile, index: number, array: Phaser.Tilemaps.Tile[])=>void; + /** * Phaser.Class */ From 080a30d7898142a03f9365494cd9bd7eab32aa87 Mon Sep 17 00:00:00 2001 From: Yuval Greenfield Date: Mon, 10 Oct 2022 10:08:50 -0700 Subject: [PATCH 4/4] More accurate "since" version for SceneType.js --- src/scene/typedefs/SceneType.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scene/typedefs/SceneType.js b/src/scene/typedefs/SceneType.js index eb0350dae..cca205dab 100644 --- a/src/scene/typedefs/SceneType.js +++ b/src/scene/typedefs/SceneType.js @@ -1,4 +1,4 @@ /** * @typedef {(Phaser.Scene|Phaser.Types.Scenes.SettingsConfig|Phaser.Types.Scenes.CreateSceneFromObjectConfig|function)} Phaser.Types.Scenes.SceneType - * @since 3.18.0 + * @since 3.60.0 */